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)); } }
public ActionResult EditCommunion(int id) { var communionRecord = _sacramentRepository.GetCommunion(id); var communion = new CommunionViewModel { Id = communionRecord.Id, BaptismNumber = communionRecord.BapitsmNumber, BaptismPlace = communionRecord.BaptismPlace, BaptismDate = communionRecord.BaptismDate.ToString("yyyy-MM-dd"), Othernames = communionRecord.Othernames, Surname = communionRecord.Surname, Date = communionRecord.DateReceived.ToString("yyyy-MM-dd"), Place = communionRecord.Place, FathersName = communionRecord.FathersName, MothersName = communionRecord.MothersName, Minister = communionRecord.NameOfMinister, CreateDate = communionRecord.CreateDate }; return(View(communion)); }