public PartialViewResult IndexLessonsAddGridView(LL_IndexGridRowModel rowModel) { dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned); BusinessUnitModel objBU = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId); if (ModelState.IsValid) { var newLesson = new LessonLearnedModel() { DateStarted = DateTimeOffset.Now, Title = rowModel.Title, ImpactLevel = rowModel.ImpactLevel, Status = LessonsLearnedStatus.Open.ToString(), SourceForm = "Lessons Learned", SourceRigFacility = UtilitySystem.Settings.RigId, SourceBU = objBU.Id, TypeId = rowModel.TypeId }; dataModel.Add(newLesson); } else { ViewData["UpdateError"] = true; } return(IndexLessonsGridView()); }
public PartialViewResult ControlAddGridRow(LL_IndexGridRowModel rowModel, string SourceForm, int SourceFormId) { dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned); BusinessUnitModel objBU = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId); if (ModelState.IsValid) { var newLesson = new LessonLearnedModel() { DateStarted = DateTimeOffset.Now, Title = rowModel.Title, ImpactLevel = rowModel.ImpactLevel, SourceRigFacility = UtilitySystem.Settings.RigId, SourceBU = objBU.Id, TypeId = rowModel.TypeId, Status = LessonsLearnedStatus.Open.ToString(), SourceForm = SourceForm, SourceFormId = SourceFormId, SourceFormURL = Request.UrlReferrer.AbsoluteUri }; newLesson = dataModel.Add(newLesson); dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedOriginator); LessonLearnedOriginatorModel originator = new LessonLearnedOriginatorModel(); originator.LessonId = newLesson.Id; string key = HttpContext.Session.SessionID + "_UserSessionInfo"; UserSession userSession = (UserSession)HttpContext.Session[key]; originator.PassportId = userSession.UserId; originator.RigFacility = UtilitySystem.Settings.RigId; dataModel.Add(originator); } else { ViewBag.UpdateError = string.Join(",", ModelState.Values.SelectMany(e => e.Errors).Select(e => e.ErrorMessage)); } return(Control(SourceForm, SourceFormId)); }