public ActionResult MOM(ProjectMom objmom) { DSRCManagementSystemEntities1 ob = new DSRCManagementSystemEntities1(); objmom.ProjectId = Convert.ToInt32(System.Web.HttpContext.Current.Application["agenda"]); var agenda = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.AgendaDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x.Agenda).FirstOrDefault(); var feedback = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.FeedbackDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x.Feedback).FirstOrDefault(); var mom = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.FeedbackDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x.MOM).FirstOrDefault(); if (agenda != null && feedback != null && mom == null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); var fed = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.FeedbackDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x).FirstOrDefault(); fed.MOM = objmom.ProjectMOM; fed.ProjectId = objmom.ProjectId; fed.MOMDate = System.DateTime.Now; ob.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (agenda == null && feedback != null && mom == null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); var age = obj.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.FeedbackDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x).FirstOrDefault(); age.MOM = objmom.ProjectMOM; age.MOMDate = System.DateTime.Now; age.ProjectId = objmom.ProjectId; obj.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (agenda != null && feedback == null && mom == null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); var age = obj.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.AgendaDate) == DateTime.Today.Date && x.ProjectId == objmom.ProjectId).Select(x => x).FirstOrDefault(); age.MOM = objmom.ProjectMOM; age.MOMDate = System.DateTime.Now; age.ProjectId = objmom.ProjectId; obj.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (agenda == null && feedback == null && mom == null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback objd = new DSRCManagementSystem.AgendaFeedback(); objd.MOM = objmom.ProjectMOM; objd.ProjectId = objmom.ProjectId; objd.MOMDate = System.DateTime.Now; obj.AddToAgendaFeedbacks(objd); obj.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (agenda == null && feedback == null && mom != null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback objd = new DSRCManagementSystem.AgendaFeedback(); objd.MOM = objmom.ProjectMOM; objd.ProjectId = objmom.ProjectId; objd.MOMDate = System.DateTime.Now; obj.AddToAgendaFeedbacks(objd); obj.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (agenda != null && feedback != null && mom != null) { DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback objd = new DSRCManagementSystem.AgendaFeedback(); objd.MOM = objmom.ProjectMOM; objd.ProjectId = objmom.ProjectId; objd.MOMDate = System.DateTime.Now; obj.AddToAgendaFeedbacks(objd); obj.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } return(View()); }
public ActionResult ProjectFeedBack(ProjectFeedBack ovj, AgandaForProject objagenda) { ovj.UserId = Convert.ToInt32(System.Web.HttpContext.Current.Application["id"]); DSRCManagementSystemEntities1 ob = new DSRCManagementSystemEntities1(); var value = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.AgendaDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(x => x.Agenda).FirstOrDefault(); var feedback = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.FeedbackDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(x => x.Feedback).FirstOrDefault(); var mom = ob.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.MOMDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(x => x.MOM).FirstOrDefault(); if (value != null && Convert.ToInt32(TempData["Count"]) == 0) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); var valuefed = objdb.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.AgendaDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(o => o).FirstOrDefault(); valuefed.Feedback = ovj.Feedback; valuefed.FeedbackDate = System.DateTime.Now; objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (value == null && Convert.ToInt32(TempData["Count"]) != 0 && feedback != null && mom != null) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); var val = objdb.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.MOMDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(o => o).FirstOrDefault(); val.Feedback = ovj.Feedback; val.FeedbackDate = System.DateTime.Now; objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (value == null && Convert.ToInt32(TempData["Count"]) != 0 && feedback == null && mom != null) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback obj = new DSRCManagementSystem.AgendaFeedback(); var val = objdb.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.MOMDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(o => o).FirstOrDefault(); val.ProjectId = ovj.UserId; val.Feedback = ovj.Feedback; val.FeedbackDate = System.DateTime.Now; objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (value == null && Convert.ToInt32(TempData["Count"]) != 0 && feedback == null && mom == null) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback obj = new DSRCManagementSystem.AgendaFeedback(); obj.Feedback = ovj.Feedback; obj.FeedbackDate = System.DateTime.Now; obj.ProjectId = ovj.UserId; objdb.AddToAgendaFeedbacks(obj); objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (value == null && Convert.ToInt32(TempData["Count"]) == 0) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); DSRCManagementSystem.AgendaFeedback obj = new DSRCManagementSystem.AgendaFeedback(); obj.Feedback = ovj.Feedback; obj.FeedbackDate = System.DateTime.Now; obj.ProjectId = ovj.UserId; objdb.AddToAgendaFeedbacks(obj); objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } else if (value != null && Convert.ToInt32(TempData["Count"]) != 0) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); var valuefed = objdb.AgendaFeedbacks.Where(x => EntityFunctions.TruncateTime(x.AgendaDate) == DateTime.Today.Date && x.ProjectId == ovj.UserId).Select(o => o).FirstOrDefault(); valuefed.Feedback = ovj.Feedback; valuefed.FeedbackDate = System.DateTime.Now; objdb.SaveChanges(); return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet)); } return(View()); }