Skip to content

Instantly share code, notes, and snippets.

View cerkit's full-sized avatar

cerkit cerkit

View GitHub Profile
@cerkit
cerkit / append_on_condition.vb
Created August 15, 2014 13:13
VB.NET Appending text based on a condition - the old way...
If chkRailCar.Checked = True Then C1 = C1 & "Y" Else C1 = C1 & "N"
@cerkit
cerkit / web.config
Created August 11, 2014 14:42
Web.config example of turning off url rewrites in a subdirectory
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear/>
</rules>
</rewrite>
</system.webServer>
</configuration>
private async void cmdGetFormats_Click(object sender, EventArgs e)
{
lbFormats.DataSource = (await _service.Get()).ToList();
lbFormats.DisplayMember = "Description";
}
AlbumFormatService _service;
public frmMain()
{
InitializeComponent();
_service = new AlbumFormatService();
}
using PortableClient.WebApi.Dal.Interfaces;
using RecordKeeper.Portable.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PortableClient.WebApi.Dal.Services
{
public class AlbumFormatService : IEntityService<AlbumFormat>
{
private static readonly string API_PATH = "AlbumFormat";
using Newtonsoft.Json;
using RecordKeeper.Portable.Models;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace PortableClient.WebApi.Dal.Services
@cerkit
cerkit / IEntityService.cs
Created March 25, 2014 19:09
The core interface for defining an service for retrieving Entities from a WebAPI
using RecordKeeper.Portable.Models;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace PortableClient.WebApi.Dal.Interfaces
{
public interface IEntityService<TEntity> where TEntity : EntityBase
{
Task<IEnumerable<TEntity>> Get(ICredentials credentials = null);
@cerkit
cerkit / AlbumFormat.xml
Created March 25, 2014 13:07
The results from calling /api/AlbumFormat from Chrome
<ArrayOfAlbumFormat xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/RecordKeeper.Portable.Models">
<AlbumFormat>
<Description>Compact Disc</Description>
<Id>CD</Id>
</AlbumFormat>
<AlbumFormat>
<Description>Vinyl Record</Description>
<Id>Record</Id>
</AlbumFormat>
</ArrayOfAlbumFormat>
@cerkit
cerkit / AlbumFormat.json
Created March 25, 2014 13:05
The results from calling /api/AlbumFormat
[{"Id":"CD","Description":"Compact Disc"},{"Id":"Record","Description":"Vinyl Record"}]
@cerkit
cerkit / AlbumFormatController.cs
Last active August 29, 2015 13:57
The Controller responsible for retrieving the album format information from the data store
namespace RecordKeeperApi.Controllers
{
public class AlbumFormatController : ApiController
{
private IFormatRepository _repository;
public AlbumFormatController() : this(new FormatRepository()) { }
public AlbumFormatController(IFormatRepository repository)
{
_repository = repository;