public IHttpActionResult CreateSpecial(SpecialDto patronDto) { if (!ModelState.IsValid) { return(BadRequest()); } var special = Mapper.Map <SpecialDto, Special>(patronDto); _context.Specials.Add(special); _context.SaveChanges(); patronDto.Id = special.Id; return(Created(new Uri(Request.RequestUri + "/" + special.Id), patronDto)); }
public void UpdateSpecial(int id, SpecialDto patronDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var specialInDb = _context.Specials.SingleOrDefault(c => c.Id == id); if (patronDto == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Mapper.Map <SpecialDto, Special>(patronDto, specialInDb); _context.SaveChanges(); }