public HttpResponseMessage updateSettingGroupPolicy([FromBody] TicketGroupPolicyDto instance) { if (ticketService.isGroupPolicyExisted(instance)) { return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, new { msg = "This Group Policy was existed" })); } else { return(Request.CreateResponse(HttpStatusCode.OK, ticketService.updateGroupPolicy(instance))); } }
public Boolean isGroupPoliciesExisted(TicketGroupPolicyDto instance) { Boolean existed = false; var sqlString = @"SELECT count(*) FROM TICKET.GROUP_POLICY A WHERE (@id > 0 OR RTRIM(LTRIM(LOWER(A.GROUP_NAME))) = RTRIM(LTRIM(LOWER(@name)))) AND (@id <= 0 OR (A.ID != @id AND RTRIM(LTRIM(LOWER(A.GROUP_NAME))) = RTRIM(LTRIM(LOWER(@name)))))"; try { int total = DbContext.Database.SqlQuery <int>(sqlString, new object[] { new SqlParameter("@id", instance.id), new SqlParameter("@name", instance.groupName) }).FirstOrDefault <int>(); if (total > 0) { existed = true; } } catch (Exception e) { Console.Write("e ", e.InnerException); } return(existed); }
public TicketGroupPolicy addNewGroupPolicy(TicketGroupPolicyDto instance) { TicketGroupPolicy gp = createGroupPolicyObject(instance); try { groupPolicyRepo.Add(gp); DateTime currentDate = DateTime.Now; foreach (GroupPolicyAssignTeamListDto dto in instance.assignTeamList) { TicketGroupPolicyTeamAssign t = new TicketGroupPolicyTeamAssign(); t.GroupPolicyId = gp.Id; t.TeamId = dto.teamId; t.CreatedDate = currentDate; t.Status = "ACTIVE"; groupPolicyTeamAssignRepo.Add(t); } foreach (GroupPolicyAssignTeamListDto dto in instance.assignReportLimitAccessTeamList) { TicketGroupPolicyReportAssign t = new TicketGroupPolicyReportAssign(); t.GroupPolicyId = gp.Id; t.TeamId = dto.teamId; t.CreatedDate = currentDate; t.Status = "ACTIVE"; groupPolicyReportAssignRepo.Add(t); } return(gp); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(gp); } }
private TicketGroupPolicy createGroupPolicyObject(TicketGroupPolicyDto instance) { TicketGroupPolicy groupPolicy = new TicketGroupPolicy(); groupPolicy.Description = instance.description; groupPolicy.GroupName = instance.groupName; groupPolicy.Status = instance.status; groupPolicy.LimitAccess = instance.limitAccess; groupPolicy.NewTicketNotify = instance.newTicketNotify; groupPolicy.AssignedNotify = instance.assignedNotify; groupPolicy.ReplyNotify = instance.replyNotify; groupPolicy.ChangeStatusNotify = instance.changeStatusNotify; groupPolicy.CreateTicket = instance.createTicket; groupPolicy.EditTicket = instance.editTicket; groupPolicy.ChangeStatus = instance.changeStatus; groupPolicy.PostTicket = instance.postTicket; groupPolicy.CloseTicket = instance.closeTicket; groupPolicy.AssignTicket = instance.assignTicket; groupPolicy.MergeTicket = instance.mergeTicket; groupPolicy.DeleteTicket = instance.deleteTicket; groupPolicy.SubTicket = instance.subTicket; groupPolicy.ReportAccess = instance.reportAccess; return(groupPolicy); }
public Boolean isGroupPolicyExisted(TicketGroupPolicyDto instance) { return(groupPolicyRepo.isGroupPoliciesExisted(instance)); }
public TicketGroupPolicy updateGroupPolicy(TicketGroupPolicyDto instance) { TicketGroupPolicy gp = createGroupPolicyObject(instance); try { gp.Id = instance.id; groupPolicyRepo.Update(gp); DateTime currentDate = DateTime.Now; //remove priouse ones foreach (TicketGroupPolicyTeamsDto obj in groupPolicyTeamAssignRepo.getListByPartners(0, gp.Id)) { TicketGroupPolicyTeamAssign gpTa = groupPolicyTeamAssignRepo.GetById(obj.id); gpTa.CreatedDate = currentDate; gpTa.Status = "DELETE"; groupPolicyTeamAssignRepo.Update(gpTa); } foreach (TicketGroupPolicyTeamsDto obj in groupPolicyReportAssignRepo.getListByPartners(0, gp.Id)) { TicketGroupPolicyReportAssign gpTa = groupPolicyReportAssignRepo.GetById(obj.id); gpTa.CreatedDate = currentDate; gpTa.Status = "DELETE"; groupPolicyReportAssignRepo.Update(gpTa); } IEnumerable <GroupPolicyAssignTeamListDto> gpTeamAssignList = instance.assignTeamList; foreach (GroupPolicyAssignTeamListDto dto in gpTeamAssignList) { TicketGroupPolicyTeamAssign gpTaObj = new TicketGroupPolicyTeamAssign(); gpTaObj.CreatedDate = currentDate; gpTaObj.TeamId = dto.teamId; gpTaObj.GroupPolicyId = gp.Id; gpTaObj.Status = "ACTIVE"; gpTaObj.ModifiedDate = currentDate; gpTaObj.Description = "Team assigned"; groupPolicyTeamAssignRepo.Add(gpTaObj); } IEnumerable <GroupPolicyAssignTeamListDto> gpReportAssignList = instance.assignReportLimitAccessTeamList; foreach (GroupPolicyAssignTeamListDto dto in gpReportAssignList) { TicketGroupPolicyReportAssign gpTaObj = new TicketGroupPolicyReportAssign(); gpTaObj.CreatedDate = currentDate; gpTaObj.TeamId = dto.teamId; gpTaObj.GroupPolicyId = gp.Id; gpTaObj.Status = "ACTIVE"; gpTaObj.ModifiedDate = currentDate; gpTaObj.Description = "Team assigned"; groupPolicyReportAssignRepo.Add(gpTaObj); } return(gp); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(gp); } }