public static Allergies AllergiesDtoToAllergies(AllergiesDto dto) { Allergies allergy = new Allergies(); allergy.Id = dto.Id; allergy.Name = dto.Name; return(allergy); }
public static AllergiesDto AllergiesToAllergiesDto(Allergies allergy) { AllergiesDto dto = new AllergiesDto(); dto.Id = allergy.Id; dto.Name = allergy.Name; dto.MedicalRecordId = allergy.MedicalRecordId; return(dto); }
public void PutAllergies(int id, AllergiesDto allergiesDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var allergies = _context.Allergies.SingleOrDefault(a => a.AllergiesId == id); if (allergies == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Mapper.Map(allergiesDto, allergies); _context.SaveChanges(); }