This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string PostImage(byte[] imageBytes) | |
| { | |
| string output; | |
| var boundary = GetBoundary(); //boundaries are placed between every form value and file in a MIME message | |
| var boundaryFormatted = string.Format("--{0}\r\n\r\n", boundary); | |
| var boundaryBytes = Encoding.ASCII.GetBytes(boundaryFormatted); //this is ascii, but later on everything is encoded in UTF8. Why, you ask? I do not know. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataTablesController : ApiController | |
| { | |
| private readonly ICustomerRepository _customerRepository; | |
| public DataTablesController(ICustomerRepository customerRepository) | |
| { | |
| _customerRepository = customerRepository; | |
| } | |
| public DataTableResult Get([FromUri]DataTableParameters parameters) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataTableParameters | |
| { | |
| /// <summary> | |
| /// Draw counter which is used by data tables to ensure ajax requests are drawn in sequence | |
| /// </summary> | |
| public int draw { get; set; } | |
| /// <summary> | |
| /// Paging first record indicator, the start point of the current data | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataTableResult | |
| { | |
| /// <summary> | |
| /// Response to the draw from DataTablesParameters, always cast the parameter value to int before returning it to prevent XSS | |
| /// </summary> | |
| public int draw { get; set; } | |
| /// <summary> | |
| /// Total records prior to filtering (in DB) | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using System.Web.Http; | |
| using Customer.Models; | |
| namespace Customer.api | |
| { | |
| public class DataTablesController : ApiController | |
| { | |
| private readonly ICustomerRepository _customerRepository; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [TestFixture] | |
| public class when_getting_employee | |
| { | |
| [Test] | |
| public void then_should_return_ok_result_given_employee_id() | |
| { | |
| // Arrange | |
| var controller = new EmployeeController(new Mock<IEmployeeRepository>().Object); | |
| // Act |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function disableChecker(checkSelector, disableValue, targetSelector) { | |
| var optionValue = $(checkSelector).val(); | |
| if (optionValue === disableValue) { | |
| $(targetSelector).prop("disabled", true); //Disable target | |
| } else { | |
| $(targetSelector).prop("disabled", false); //Enable target | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RequiredIfAttributeTests | |
| { | |
| [TestFixture] | |
| public class when_validating_required_if_attribute | |
| { | |
| private class TestModel | |
| { | |
| [RequiredIf("Property2", true)] | |
| public int? Property1 { get; set; } | |
| public bool Property2 { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)] | |
| public class AtLeastOneTrueAttribute : ValidationAttribute | |
| { | |
| private readonly string _targetProperty; | |
| public AtLeastOneTrueAttribute(string targetProperty) | |
| { | |
| _targetProperty = targetProperty; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Zipcode : ApiController | |
| { | |
| private readonly ZipcodeRepository zipcodeRepository; | |
| public Zipcode(ZipcodeRepository zipcodeRepository) | |
| { | |
| this.zipcodeRepository = zipcodeRepository; | |
| } | |
| public OkNegotiatedContentResult<string> Get(string zipcode, string state) |