public ActionResult Create(ComplaintLogViewModel collection) { try { // collection.CleaningStaffByLocation.ApprovedBy = User.Identity.Name == "" ? "Naveed" : User.Identity.Name; if (collection.ComplainLog.Id > 0) { //collection.StudentFeedBackReport.ModifiedOn = DateTime.Now; //collection.StudentFeedBackReport.ModifiedBy = User.Identity.Name == "" ? "Naveed" : User.Identity.Name; unitofwork.ComplainLogRepository.Update(collection.ComplainLog); } else { //collection.StudentFeedBackReport.CreatedOn = DateTime.Now; //collection.StudentFeedBackReport.CreatedBy = User.Identity.Name == "" ? "Naveed" : User.Identity.Name; unitofwork.ComplainLogRepository.Insert(collection.ComplainLog); } unitofwork.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: StudentFeedBackReport/Create public ActionResult Create(int?id) { ComplaintLogViewModel model = new ComplaintLogViewModel(); model.StusentListItems = LoadStudents(); if (id > 0) { model.ComplainLog = db.ComplainLogs.Where(x => x.Id == id).FirstOrDefault(); } return(View(model)); }