Esempio n. 1
0
        public static Allergies AllergiesDtoToAllergies(AllergiesDto dto)
        {
            Allergies allergy = new Allergies();

            allergy.Id   = dto.Id;
            allergy.Name = dto.Name;
            return(allergy);
        }
Esempio n. 2
0
        public static AllergiesDto AllergiesToAllergiesDto(Allergies allergy)
        {
            AllergiesDto dto = new AllergiesDto();

            dto.Id              = allergy.Id;
            dto.Name            = allergy.Name;
            dto.MedicalRecordId = allergy.MedicalRecordId;
            return(dto);
        }
Esempio n. 3
0
        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();
        }