public ActionResult Edit(int?Id) { var KPICatalog = KPICatalogRepository.GetKPICatalogById(Id.Value); if (KPICatalog != null && KPICatalog.IsDeleted != true) { var model = new KPICatalogViewModel(); AutoMapper.Mapper.Map(KPICatalog, model); //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1) //{ // TempData["FailedMessage"] = "NotOwner"; // return RedirectToAction("Index"); //} //model.DepartmentSelectList = Helpers.SelectListHelper.GetSelectList_Department(null); return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Index(int KPILogDetailId, List <KPILogDetail_ItemViewModel> model, int KPICatalogId) { double totalScores = 0; foreach (var item in model) { KPILogDetail_Item KPILogDetail_Item = KPILogDetail_ItemRepository.GetKPILogDetail_ItemById(item.Id); KPILogDetail_Item.ModifiedDate = DateTime.Now; KPILogDetail_Item.ModifiedUserId = WebSecurity.CurrentUserId; KPILogDetail_Item.AchieveScore = item.AchieveScore; if (KPILogDetail_Item.TargetScore_To > KPILogDetail_Item.TargetScore_From) { KPILogDetail_Item.AchieveKPIWeight = KPILogDetail_Item.AchieveScore / KPILogDetail_Item.TargetScore_To * KPILogDetail_Item.KPIWeight; } else { KPILogDetail_Item.AchieveKPIWeight = (1 - KPILogDetail_Item.AchieveScore / KPILogDetail_Item.TargetScore_From) * KPILogDetail_Item.KPIWeight; } KPILogDetail_ItemRepository.UpdateKPILogDetail_Item(KPILogDetail_Item); totalScores += KPILogDetail_Item.AchieveKPIWeight; } KPILogDetail KPILogDetail = KPILogDetailRepository.GetAllKPILogDetail() .Where(item => item.Id == KPILogDetailId) .FirstOrDefault(); if (KPILogDetail != null) { var KPICatalog = KPICatalogRepository.GetKPICatalogById(KPICatalogId); if (totalScores >= KPICatalog.ExpectScore) { KPILogDetail.Completed = true; } else { KPILogDetail.Completed = false; } KPILogDetail.AchieveKPIWeight = totalScores; KPILogDetailRepository.UpdateKPILogDetail(KPILogDetail); } return(RedirectToAction("Index", new { KPILogDetailId = KPILogDetailId, KPICatalogId = KPICatalogId })); }
public ActionResult Create(KPILogViewModel model) { if (ModelState.IsValid) { var KPILog = new KPILog(); AutoMapper.Mapper.Map(model, KPILog); KPILog.IsDeleted = false; KPILog.CreatedUserId = WebSecurity.CurrentUserId; KPILog.ModifiedUserId = WebSecurity.CurrentUserId; KPILog.AssignedUserId = WebSecurity.CurrentUserId; KPILog.CreatedDate = DateTime.Now; KPILog.ModifiedDate = DateTime.Now; //Lấy bảng thông số KPI var KPICatalog = KPICatalogRepository.GetKPICatalogById(model.KPICatalogId); KPILog.Description = KPICatalog.Description; KPILog.ExpectScore = KPICatalog.ExpectScore; KPILogRepository.InsertKPILog(KPILog); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Detail", new { Id = KPILog.Id })); } return(View(model)); }