Beispiel #1
0
        public ActionResult <bool> UpdateItem(int id, [FromBody] Records entity)
        {
            try
            {
                var     c        = new vaccineContext();
                Records existing = c.Records.Where(p => p.Id == id).SingleOrDefault();
                //values
                existing.Citizen      = entity.Citizen == 0 ? existing.Citizen : entity.Citizen;
                existing.Vaccine      = entity.Vaccine == 0 ? existing.Vaccine : entity.Vaccine;
                existing.Province     = entity.Province == 0 ? existing.Province : entity.Province;
                existing.FirstVacDate = entity.FirstVacDate is null ? existing.FirstVacDate : entity.FirstVacDate;
                existing.LastVacDate  = entity.LastVacDate is null ? existing.LastVacDate : entity.LastVacDate;



                c.Update(existing);
                c.SaveChanges();

                return(true);
            }
            catch (System.Exception)
            {
                return(BadRequest());
            }
        }
Beispiel #2
0
        public ActionResult <bool> UpdateItem(int id, [FromBody] Citizens entity)
        {
            try
            {
                var      c        = new vaccineContext();
                Citizens existing = c.Citizens.Where(p => p.Id == id).SingleOrDefault();
                //values
                existing.FirstName = entity.FirstName is null ? existing.FirstName : entity.FirstName;
                existing.LastName  = entity.LastName is null ? existing.LastName : entity.LastName;
                existing.Phone     = entity.Phone is null ? existing.Phone : entity.Phone;
                existing.IdNumber  = entity.IdNumber is null ? existing.IdNumber : entity.IdNumber;
                existing.BirthDate = entity.BirthDate is null ? existing.BirthDate : entity.BirthDate;



                c.Update(existing);
                c.SaveChanges();

                return(true);
            }
            catch (System.Exception)
            {
                return(BadRequest());
            }
        }
Beispiel #3
0
        public ActionResult <bool> UpdateItem(int id, [FromBody] Provinces entity)
        {
            try
            {
                var       c        = new vaccineContext();
                Provinces existing = c.Provinces.Where(p => p.Id == id).SingleOrDefault();
                //values
                existing.Name = entity.Name is null ? existing.Name : entity.Name;

                c.Update(existing);
                c.SaveChanges();

                return(true);
            }
            catch (System.Exception)
            {
                return(BadRequest());
            }
        }