public void SaveSla(SlaItemEntity slaItemEntity) { _context.Configuration.AutoDetectChangesEnabled = false; try { var isEdit = slaItemEntity.SlaId.HasValue; TB_M_SLA sla; if (!isEdit) { //add sla = new TB_M_SLA(); } else { //edit sla = _context.TB_M_SLA.SingleOrDefault(s => s.SLA_ID == slaItemEntity.SlaId.Value); if (sla == null) { throw new CustomException("Cannot Update SLA: ID={0} does not exist", slaItemEntity.AreaId); } } sla.PRODUCT_ID = slaItemEntity.ProductId; sla.CAMPAIGNSERVICE_ID = slaItemEntity.CampaignServiceId; sla.AREA_ID = slaItemEntity.AreaId; sla.SUBAREA_ID = slaItemEntity.SubAreaId; sla.TYPE_ID = slaItemEntity.TypeId; sla.CHANNEL_ID = slaItemEntity.ChannelId; sla.SR_STATUS_ID = slaItemEntity.SrStatusId; sla.SLA_MINUTE = slaItemEntity.SlaMinute; sla.SLA_TIMES = slaItemEntity.SlaTimes; sla.SLA_DAY = slaItemEntity.SlaDay; sla.SLA_IS_ACTIVE = true; sla.UPDATE_DATE = DateTime.Now; sla.UPDATE_USER = slaItemEntity.UserId; if (!isEdit) { sla.CREATE_DATE = DateTime.Now; sla.CREATE_USER = slaItemEntity.UserId; _context.TB_M_SLA.Add(sla); } else { SetEntryStateModified(sla); } Save(); } finally { _context.Configuration.AutoDetectChangesEnabled = true; } }
public void SaveSLA(SlaItemEntity slaItemEntity) { _slaDataAccess = new SlaDataAccess(_context); _slaDataAccess.SaveSla(slaItemEntity); }
public JsonResult Save(SlaSaveModel slaSaveVM) { Logger.Info(_logMsg.Clear().SetPrefixMsg("SLA Save").ToInputLogString()); try { if (ModelState.IsValid) { _slaFacade = new SlaFacade(); //validate duplicate sla information var isValidate = _slaFacade.ValidateSla( slaSaveVM.SlaId, slaSaveVM.ProductId, slaSaveVM.CampaignServiceId, slaSaveVM.AreaId, slaSaveVM.SubAreaId, slaSaveVM.TypeId, slaSaveVM.ChannelId, slaSaveVM.SrStatusId); if (!isValidate) { return(Json(new { Valid = false, Error = Resource.Error_SaveFailedDuplicate })); } SlaItemEntity slaItemEntity = new SlaItemEntity() { SlaId = slaSaveVM.SlaId, ProductId = slaSaveVM.ProductId, CampaignServiceId = slaSaveVM.CampaignServiceId, AreaId = slaSaveVM.AreaId, SubAreaId = slaSaveVM.SubAreaId, TypeId = slaSaveVM.TypeId, ChannelId = slaSaveVM.ChannelId, SrStatusId = slaSaveVM.SrStatusId, SlaMinute = slaSaveVM.SlaMinute, SlaTimes = slaSaveVM.SlaTimes, SlaDay = slaSaveVM.SlaDay, UserId = UserInfo.UserId }; _slaFacade.SaveSLA(slaItemEntity); return(Json(new { IsSuccess = true })); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors(), })); } catch (Exception ex) { Logger.Info(_logMsg.Clear().SetPrefixMsg("SLA Save").ToFailLogString()); return(Json(new { Valid = false, Error = string.Format(CultureInfo.InvariantCulture, "Technical Error : {0}", ex.Message), })); } }
public ActionResult Edit(int?slaId) { _srChannelFacade = new SrChannelFacade(); _srStatusFacade = new SrStatusFacade(); _slaFacade = new SlaFacade(); var editSlaVM = new SlaEditModel(); var srChannelList = _srChannelFacade.GetSrChannelList(); editSlaVM.SrChannelList = srChannelList.Select(item => new SelectListItem() { Text = item.ChannelName, Value = item.ChannelId.ToString(CultureInfo.InvariantCulture) }).ToList(); editSlaVM.SrChannelList.Insert(0, new SelectListItem() { Text = "กรุณาเลือก", Value = "" }); var srStatusList = _srStatusFacade.GetSrStatusList(); editSlaVM.SrStatusList = srStatusList.Select(item => new SelectListItem() { Text = item.SRStatusName, Value = item.SRStatusId.ToString(CultureInfo.InvariantCulture) }).ToList(); editSlaVM.SrStatusList.Insert(0, new SelectListItem() { Text = "กรุณาเลือก", Value = "" }); if (slaId.HasValue) { SlaItemEntity slaItemEntity = _slaFacade.GetSlaById(slaId); if (slaItemEntity != null && slaItemEntity.SlaId.HasValue) { editSlaVM.SlaId = slaItemEntity.SlaId; editSlaVM.ProductId = slaItemEntity.ProductId; editSlaVM.ProductGroupId = slaItemEntity.ProductGroupId; editSlaVM.CampaignServiceId = slaItemEntity.CampaignServiceId; editSlaVM.AreaId = slaItemEntity.AreaId; editSlaVM.SubAreaId = slaItemEntity.SubAreaId; editSlaVM.TypeId = slaItemEntity.TypeId; editSlaVM.ProductName = slaItemEntity.ProductName; editSlaVM.ProductGroupName = slaItemEntity.ProductGroupName; editSlaVM.CampaignServiceName = slaItemEntity.CampaignName; editSlaVM.AreaName = slaItemEntity.AreaName; editSlaVM.SubAreaName = slaItemEntity.SubAreaName; editSlaVM.TypeName = slaItemEntity.TypeName; editSlaVM.ChannelId = slaItemEntity.ChannelId; editSlaVM.SrChannelId = slaItemEntity.ChannelId; editSlaVM.SrStatusId = slaItemEntity.SrStatusId; editSlaVM.SlaMinute = slaItemEntity.SlaMinute; editSlaVM.SlaTimes = slaItemEntity.SlaTimes; editSlaVM.SlaDay = slaItemEntity.SlaDay; editSlaVM.CreateUserName = slaItemEntity.CreateUser != null ? slaItemEntity.CreateUser.FullName : ""; editSlaVM.CreateDate = DateUtil.ToStringAsDateTime(slaItemEntity.CreateDate); editSlaVM.UpdateUserName = slaItemEntity.UpdateUser != null ? slaItemEntity.UpdateUser.FullName : ""; editSlaVM.UpdateDate = DateUtil.ToStringAsDateTime(slaItemEntity.UpdateDate); } } return(View(editSlaVM)); }