public IActionResult Edit(int id) { try { NotificationCenterVM ncvm = new NotificationCenterVM(); var notfi = _db.Notifications.First(c => c.id == id); ncvm.taxForm = _db.TaxForms.First(c => c.ID == notfi.TaxFormId); ncvm.Notification = notfi; ncvm.Notifications = _db.Notifications.Where(c => c.UserId == ncvm.taxForm.UserID).ToList(); return(View("Index", ncvm)); } catch (Exception) { throw; } }
public IActionResult Index(NotificationCenterVM model) { try { var t = _db.TaxForms.First(c => c.ID == model.taxForm.ID); model.Notification.CreatedOn = DateTime.Now; model.Notification.UpdatedOn = DateTime.Now; model.Notification.UserId = model.taxForm.UserID; model.Notification.SentByAdmin = true; model.Notification.isDeleted = false; model.Notification.Read = false; model.Notification.TaxFormId = model.taxForm.ID; t.Notifications.Add(model.Notification); _db.Update(t); _db.SaveChanges(); return(RedirectToAction("Index", "Home", new { area = "pnlaccess" })); } catch (Exception ex) { throw; } }
public IActionResult Index(int id) { try { NotificationCenterVM ncvm = new NotificationCenterVM(); ncvm.taxForm = _db.TaxForms.First(c => c.ID == id); ncvm.Notification = new Notifications(); ncvm.Notification.CreatedOn = DateTime.Now; ncvm.Notification.UpdatedOn = DateTime.Now; ncvm.Notification.UserId = ncvm.taxForm.UserID; ncvm.Notification.SentByAdmin = true; ncvm.Notification.isDeleted = false; ncvm.Notification.Read = false; ncvm.ProfilePicture = (_db.Users.Any(c => c.Id == ncvm.taxForm.UserID))? _db.Users.First(c => c.Id == ncvm.taxForm.UserID).ProfilePicture:null; ncvm.Notifications = _db.Notifications.Where(c => c.UserId == ncvm.taxForm.UserID).ToList(); return(View(ncvm)); } catch (Exception) { throw; } }