public ActionResult ControlAddReview(ReviewModel reviewModel, string SourceForm, string SourceFormId) { if (ModelState.IsValid) { dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Review); BusinessUnitModel businessUnit = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId); ReviewModel newReview = new ReviewModel() { RigId = UtilitySystem.Settings.RigId, Comment = reviewModel.Comment, ReviewerPassportId = reviewModel.ReviewerPassportId, RequestedBy = UtilitySystem.CurrentUserId, SourceBU = businessUnit.Id, SourceForm = SourceForm, SourceFormId = SourceFormId.ToString(), DateCreated = DateTimeOffset.Now }; dataModel.Add(newReview); ServiceSystem.AddTask(sourceForm: "Review", sourceFormId: SourceFormId, assigneeUserId: newReview.ReviewerPassportId, dueDate: reviewModel.DueDate, sourceFormUrl: Request.UrlReferrer.PathAndQuery); } else { ViewData["UpdateError"] = true; } return(Control(SourceForm, SourceFormId)); }
// GET: BusinessUnit/Details/5 public ActionResult Details(Guid id) { BusinessUnitModel businessUnitDetails = new BusinessUnitModel(); businessUnitDetails = businessUnitRepository.GetBusinessUnitByID(id); return(View("DetailsBusinessUnit", businessUnitDetails)); }
private string AddUnit(string input) { if (string.IsNullOrEmpty(input)) { return(JsonExtensions.ToJson(new MyHttpResult { result = false, msg = "提交数据错误!" })); } BusinessUnitModel bu = JsonExtensions.FromJson <BusinessUnitModel>(input); var userid = ((UserModel)Public.User_Info).id; bu.createby = Convert.ToInt32(1); bu.createon = DateTime.Now; int iResult; if (bu.id == 0)//新增id=0 { iResult = bu.Insert(); } else { iResult = bu.Update(); } return(JsonExtensions.ToJson(new MyHttpResult { result = iResult > 0 ? true : false, })); }
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()); }
// GET: BusinessUnit/Edit/5 public ActionResult Edit(Guid id) { BusinessUnitModel businessUnitModel = businessUnitRepository.GetBusinessUnitByID(id); var managers = employeeRepository.GetAllEmployeesWherePositionIsBusinessUnitManager(); SelectList listmanagers = new SelectList(managers, "IDEmployee", "FullName"); ViewData["manager"] = listmanagers; return(View("EditBusinessUnit", businessUnitModel)); }
public void UpdateBusinessUnit(BusinessUnitModel businessUnitModel) { BusinessUnit dbBusinessUnit = dbContext.BusinessUnits.FirstOrDefault(x => x.IDBusinessUnit == businessUnitModel.IDBusinessUnit); if (dbBusinessUnit != null) { dbBusinessUnit.IDBusinessUnit = businessUnitModel.IDBusinessUnit; dbBusinessUnit.Name = businessUnitModel.Name; dbBusinessUnit.IDBusinessUnitManager = businessUnitModel.IDBusinessUnitManager; dbContext.SubmitChanges(); } }
private BusinessUnit MapModelToDbObject(BusinessUnitModel businessUnitModel) { BusinessUnit dbBusinessUnit = new BusinessUnit(); if (businessUnitModel != null) { dbBusinessUnit.IDBusinessUnit = businessUnitModel.IDBusinessUnit; dbBusinessUnit.Name = businessUnitModel.Name; dbBusinessUnit.IDBusinessUnitManager = businessUnitModel.IDBusinessUnitManager; return(dbBusinessUnit); } return(null); }
private BusinessUnitModel MapDbObjectToModel(BusinessUnit dbBusinessUnit) { BusinessUnitModel businessUnitModel = new BusinessUnitModel(); if (dbBusinessUnit != null) { businessUnitModel.IDBusinessUnit = dbBusinessUnit.IDBusinessUnit; businessUnitModel.Name = dbBusinessUnit.Name; businessUnitModel.IDBusinessUnitManager = dbBusinessUnit.IDBusinessUnitManager; if (dbBusinessUnit.Employee != null) { businessUnitModel.BusinessUnitManagerName = dbBusinessUnit.Employee.FirstName + " " + dbBusinessUnit.Employee.LastName; } return(businessUnitModel); } return(null); }
public ActionResult Edit(Guid id, FormCollection collection) { var managers = employeeRepository.GetAllEmployeesWherePositionIsBusinessUnitManager(); SelectList listmanagers = new SelectList(managers, "IDEmployee", "FullName"); ViewData["manager"] = listmanagers; try { BusinessUnitModel businessUnitModel = new BusinessUnitModel(); UpdateModel(businessUnitModel); businessUnitRepository.UpdateBusinessUnit(businessUnitModel); return(RedirectToAction("Index")); } catch { return(View("EditBusinessUnit")); } }
private BusinessUnitModel GenerateBusinessUnit(string title, string shortName, double availability) { var newBU = new BusinessUnitModel() { Title = title, ShortName = shortName, Availability = availability }; int min = newBU.Availability <0.3 ? 20 : newBU.Availability> 0.3 && newBU.Availability < 0.7 ? 55 : 85; int max = newBU.Availability <0.3 ? 30 : newBU.Availability> 0.3 && newBU.Availability < 0.7 ? 65 : 95; Random hRand = new Random(max); newBU.AvailabilityHistoric = new List <GenericDateValueModel>(); for (int j = -12; j < -1; j++) { newBU.AvailabilityHistoric.Add(new GenericDateValueModel(DateTime.Now.AddMonths(j), hRand.Next(min, max))); } newBU.ChildrenBUs = new List <BusinessUnitModel>(); return(newBU); }
/// <summary> /// <see cref="IDataService"/> /// </summary> /// <returns><see cref="IDataService"/> </returns> public BusinessUnitModel GetWorkforceData() { Random rand = new Random(DateTime.Now.Second); BusinessUnitModel items = GenerateBusinessUnit("", "", rand.NextDouble()); for (int i = 0; i < 10; i++) { var newBU = GenerateBusinessUnit($"Business Unit {i}", $"BU {i}", rand.NextDouble()); Random numUnitsRandom = new Random(i); var numUnits = numUnitsRandom.Next(1, 5); for (int j = 0; j < numUnits; j++) { var newSubBU = GenerateBusinessUnit($"Business Unit {i}", $"BU {i} - {j}", newBU.Availability); newBU.ChildrenBUs.Add(newSubBU); } items.ChildrenBUs.Add(newBU); } return(items); }
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)); }
// GET: BusinessUnit/Delete/5 public ActionResult Delete(Guid id) { BusinessUnitModel businessUnitToDelete = businessUnitRepository.GetBusinessUnitByID(id); return(View("DeleteBusinessUnit", businessUnitToDelete)); }
private void ExecuteGoBack() { SelectedBusinessUnit = BusinessUnits; }
public void InsertBusinessUnit(BusinessUnitModel businessUnitModel) { businessUnitModel.IDBusinessUnit = Guid.NewGuid(); dbContext.BusinessUnits.InsertOnSubmit(MapModelToDbObject(businessUnitModel)); dbContext.SubmitChanges(); }
public BusinessUnitModel GetBusinessUnitByID(Guid id) { BusinessUnitModel businessUnitModel = MapDbObjectToModel(dbContext.BusinessUnits.FirstOrDefault(x => x.IDBusinessUnit == id)); return(businessUnitModel); }