Esempio n. 1
0
        public bool UpdateVaccine(VaccineRUD model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Vaccines
                             .Single(e => e.VaccineId == model.VaccineId);

                entity.Name                = model.Name;
                entity.CommonName          = model.CommonName;
                entity.VaccinationSchedule = model.VaccinationSchedule;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(VaccineRUD vaccine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateVaccineServices();

            if (!service.UpdateVaccine(vaccine))
            {
                return(InternalServerError());
            }

            return(Ok());
        }