Пример #1
0
        public bool UpdateCommunion(Communion communion)
        {
            var existingcommunion = _entities.Communions.FirstOrDefault(m => m.Id == communion.Id);

            if (existingcommunion != null)
            {
                communion.CreateDate = existingcommunion.CreateDate;
                _entities.Entry(existingcommunion).CurrentValues.SetValues(communion);
                _entities.SaveChanges();
                return(true);
            }
            return(false);
        }
 public ActionResult EditCommunion(CommunionViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         var communion = new Communion()
         {
             Id             = model.Id,
             BapitsmNumber  = model.BaptismNumber,
             BaptismPlace   = model.BaptismPlace,
             BaptismDate    = DateTime.Parse(model.BaptismDate),
             Othernames     = model.Othernames,
             Surname        = model.Surname,
             DateReceived   = DateTime.Parse(model.Date),
             Place          = model.Place,
             FathersName    = model.FathersName,
             MothersName    = model.MothersName,
             NameOfMinister = model.Minister,
             Deleted        = 0,
             CreateDate     = model.CreateDate,
             UpdateDate     = DateTime.Now
         };
         if (_sacramentRepository.UpdateCommunion(communion))
         {
             var returnData = new ReturnData
             {
                 HasValue = true,
                 Message  = "Communion record was successfully updated"
             };
             TempData["returnMessage"] = returnData;
             return(RedirectToAction("Communion"));
         }
         ModelState.AddModelError(string.Empty, "There was an error completing the pdate, Please check the entries and try again");
         return(View(model));
     }
     catch (Exception e)
     {
         //error occured
         ModelState.AddModelError(string.Empty, "There was an error completing the registration, Please try again later");
         ErrorUtil.LogError(e);
         return(View(model));
     }
 }
Пример #3
0
 public bool AddCommunion(Communion communion)
 {
     _entities.Communions.Add(communion);
     _entities.SaveChanges();
     return(true);
 }