public void saveNotify(ParkNotify notifyObj, bool toDelete = false) { if (notifyObj.Id != 0) { var existingObj = _context.ParkNotifies.Where(x => x.Id == notifyObj.Id).SingleOrDefault(); if (existingObj != null) { if (toDelete) { existingObj.IsNotified = true; } else { existingObj.Name = notifyObj.Name; existingObj.Email = notifyObj.Email; existingObj.Zip = notifyObj.Zip; } _context.Entry(existingObj).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } else { notifyObj.CreatedOn = DateTime.Now; notifyObj.IsNotified = false; _context.ParkNotifies.Add(notifyObj); _context.SaveChanges(); } }
public bool SaveParkNotify(ParkNotify notify) { notify.IsNotified = false; notify.CreatedOn = DateTime.Now; _context.ParkNotifies.Add(notify); _context.SaveChanges(); return(true); }
public ActionResult deleteNotify(int id) { try { var objNotify = new ParkNotify(); objNotify.Id = id; _serviceFacade.saveNotify(objNotify, true); TempData["Success"] = true; } catch (Exception ex) { TempData["Success"] = false; } return(RedirectToAction("Notify")); }
public ActionResult Notify(NotifyViewModel model) { ParkNotify request = new ParkNotify { Name = model.Name, Zip = model.Zip, Email = model.Email }; bool success = _serviceFacade.SaveParkNotify(request); ViewBag.success = success; if (!success) { return(View(model)); } else { return(View()); } }