public static dynamic UpdateTaskStatus(int taskid, int status, string updatedby)
        {
            CustomResponse objres = new CustomResponse();

            try
            {
                using (var objcontext = new Db_Zon_Test_techsupportEntities())
                {
                    Mst_Task     objtask      = objcontext.Mst_Task.Where(x => x.ID == taskid).FirstOrDefault();
                    Trans_Ticket objtasktrans = new Trans_Ticket();
                    objtasktrans.TaskID         = taskid;
                    objtasktrans.CreatedBy      = updatedby;
                    objtasktrans.CreatedDate    = DateTime.Now;
                    objtasktrans.O_Task_Status  = objtask.Task_Status;
                    objtasktrans.N_Task_Statuus = status;
                    objcontext.Trans_Ticket.Add(objtasktrans);
                    objtask.Task_Status = status;
                    objtask.UpdatedBy   = updatedby;
                    objcontext.SaveChanges();


                    objres.Message  = "Success";
                    objres.Response = objtask;
                    objres.Status   = CustomResponseStatus.Successful;
                    return(objres);
                }
            }
            catch (Exception ex)
            {
                objres.Message  = ex.Message;
                objres.Response = null;
                objres.Status   = CustomResponseStatus.UnSuccessful;
                return(objres);
            }
        }
Exemplo n.º 2
0
        public static dynamic AddNewTicket(Mst_Task objnewTask)
        {
            CustomResponse objres = new CustomResponse();

            try
            {
                using (var objcontext = new Db_Zon_Test_techsupportEntities())
                {
                    // get short name of the project and get the max count of the tickets and use it as display name
                    string shortname = objcontext.Mst_Project.Where(x => x.ID == objnewTask.ProjectID).FirstOrDefault().ShortName;
                    int    maxcount  = objcontext.Mst_Task.Where(x => x.ProjectID == objnewTask.ProjectID).Count();
                    objnewTask.TaskDisplayName = shortname + '-' + (maxcount + 1);
                    objcontext.Mst_Task.Add(objnewTask);
                    objcontext.SaveChanges();
                    Trans_Ticket objtrans = new Trans_Ticket {
                        TaskID = objnewTask.ID, N_Title = objnewTask.Title, N_Description = objnewTask.Description, DisplayName = objnewTask.TaskDisplayName, CreatedDate = DateTime.Now, CreatedBy = objnewTask.CreatedBy
                    };
                    objcontext.Trans_Ticket.Add(objtrans);
                    objcontext.SaveChanges();
                    objres.Message  = "Success";
                    objres.Response = objnewTask;
                    objres.Status   = CustomResponseStatus.Successful;
                    return(objres);
                }
            }
            catch (Exception ex)
            {
                objres.Message  = ex.Message;
                objres.Response = null;
                objres.Status   = CustomResponseStatus.UnSuccessful;
                return(objres);
            }
        }
        public dynamic Put(TaskDTO objtaskdto)
        {
            TaskDTO  Oldtask = (TaskDTO)TaskRepository.GetTicketDetails(objtaskdto.ID).Response;
            Mst_Task objtask = new Mst_Task {
                ID = objtaskdto.ID, CreatedBy = objtaskdto.CreatedBy, UpdatedBy = objtaskdto.UpdatedBy, Title = objtaskdto.Title, Task_Status = objtaskdto.Task_Status, Description = objtaskdto.Description, DueDate = objtaskdto.DueDate, PriorityID = objtaskdto.PriorityID, TypeID = objtaskdto.TypeID, RefereedTo = objtaskdto.RefereedTo, AssignedTo = objtaskdto.AssignedTo, AssigndedDate = objtaskdto.AssigndedDate, ProjectID = objtaskdto.ProjectID
            };
            CustomResponse res = TaskRepository.UpdateTicket(objtask);


            List <string> ObjToAddresses         = new List <string>();
            List <string> ObjFilteredToAddresses = new List <string>();

            if (res.Status == CustomResponseStatus.Successful)
            {
                ObjToAddresses.Add(objtaskdto.CreatedBy);
                ObjToAddresses.Add(objtaskdto.RefereedTo);
                ObjToAddresses.Add(objtaskdto.AssignedTo);
                // Get All Stackholders related to project
                ObjToAddresses.AddRange(ProjectRepository.GetProjectUsers(objtaskdto.ProjectID));
                ObjFilteredToAddresses = ObjToAddresses.Distinct().ToList();
                ObjFilteredToAddresses = UserRepository.GetEmailAddressesByUserIds(ObjFilteredToAddresses);
                StringBuilder sb = new StringBuilder();
                sb.Append("<table>");
                sb.Append("<tr><td><center><b>  Updated Ticket Infromation</b></center> <td></tr>");
                sb.Append("<tr><td><center> Project Name </center> <td> <td><center>" + objtaskdto.ProjectID + "  </center> <td></tr>");
                sb.Append("<tr><td><center> Ticket ID </center> <td> <td><center>" + objtaskdto.ID + "  </center> <td></tr>");
                sb.Append("<tr><td><center> Ticket Titile  </center> <td> <td><center>" + objtaskdto.Title + "  </center> <td></tr>");
                sb.Append("<tr><td><center> Ticket Description </center> <td> <td><center>" + objtaskdto.Description + "  </center> <td></tr>");
                sb.Append("<tr><td><center> Ticket Start Date </center> <td> <td><center>" + objtaskdto.AssigndedDate + "  </center> <td></tr>");
                sb.Append("<tr><td><center> Ticket Due Date </center> <td> <td><center>" + objtaskdto.DueDate + "  </center> <td></tr>");
                if (objtaskdto.PriorityID != Oldtask.PriorityID)
                {
                    sb.Append("<tr><td><center> New Priority </center> <td> <td><center>" + GenericRepository.GetPrioritynameByPid(objtaskdto.PriorityID) + "  </center> <td></tr>");
                }
                if (objtaskdto.Task_Status != Oldtask.Task_Status)
                {
                    sb.Append("<tr><td><center> New Task Status </center> <td> <td><center>" + GenericRepository.GetTaskStausByPid(objtaskdto.Task_Status) + "  </center> <td></tr>");
                }
                if (objtaskdto.TaskTypeName != Oldtask.TaskTypeName)
                {
                    sb.Append("<tr><td><center> New Task Type </center> <td> <td><center>" + GenericRepository.GetTasknameByPid(objtaskdto.TypeID) + "  </center> <td></tr>");
                }
                sb.Append("</table>");

                string subject = "Tech Support - Ticket Updtaes Information";

                foreach (var toMail in ObjFilteredToAddresses)
                {
                    MailSender.TaskStatusCreate_UpdationMail(UserReportRepository.GetFnameByEmail(toMail), subject, sb.ToString(), toMail);
                }
            }

            return(res);
        }
        public dynamic Post(TaskDTO objtaskdto)
        {
            Mst_Task objtask = new Mst_Task {
                Title = objtaskdto.Title, Task_Status = objtaskdto.Task_Status, Description = objtaskdto.Description, DueDate = objtaskdto.DueDate, PriorityID = objtaskdto.PriorityID, TypeID = objtaskdto.TypeID, RefereedTo = objtaskdto.RefereedTo, AssignedTo = objtaskdto.AssignedTo, CreatedBy = objtaskdto.CreatedBy, AssigndedDate = objtaskdto.AssigndedDate, ProjectID = objtaskdto.ProjectID, Attachment1_Name = objtaskdto.Attachment1_Name, Attachment1_Path = objtaskdto.Attachment1_Path, Attachment2_Name = objtaskdto.Attachment2_Name, Attachment2_Path = objtaskdto.Attachment2_Path, Attachment3_Name = objtaskdto.Attachment3_Name, Attachment3_Path = objtaskdto.Attachment3_Path
            };
            CustomResponse res = TaskRepository.AddNewTicket(objtask);

            if (res.Status == CustomResponseStatus.Successful)
            {
                List <UserDTO> users = UserReportRepository.GetUserProjectDetailsByProejectid(objtaskdto.ProjectID);
                users.Add(new UserDTO {
                    Email = objtaskdto.AssignedTo, RoleName = "3"
                });
                string createdbyemail = UserReportRepository.GetEmailByUid(objtaskdto.CreatedBy);

                List <string> ObjToAddresses         = new List <string>();
                List <string> ObjFilteredToAddresses = new List <string>();
                ObjToAddresses.Add(objtaskdto.AssignedTo);
                ObjToAddresses.Add(objtaskdto.RefereedTo);
                ObjToAddresses.Add(objtaskdto.CreatedBy);
                // Get All Stackholders related to project
                ObjToAddresses.AddRange(ProjectRepository.GetProjectUsers(objtaskdto.ProjectID));
                ObjFilteredToAddresses = ObjToAddresses.Distinct().ToList();
                ObjFilteredToAddresses = UserRepository.GetEmailAddressesByUserIds(ObjFilteredToAddresses);
                string subject = "Zon Ticketing System - New Ticket Information";

                StringBuilder sb = new StringBuilder();
                sb.Append("<table width=100% align='center'>");
                sb.Append("<tr><td>Task ID</td><td>" + objtask.ID + "</td></tr>");
                sb.Append("<tr><td>Task Name<center></td><td>" + objtask.Title + "</td></tr>");
                sb.Append("<tr><td>Task Description<center></td><td><center>" + objtask.Description + "</td></tr>");

                sb.Append("<tr><td>Assigned To<center></td><td><center>" + UserRepository.GetFnamebyUid(objtask.AssignedTo) + "</td></tr>");
                sb.Append("<tr><td>Reffer To<center></td><td><center>" + UserRepository.GetFnamebyUid(objtask.RefereedTo) + "</td></tr>");
                sb.Append("</table>");

                foreach (var toMail in ObjFilteredToAddresses)
                {
                    MailSender.TaskStatusCreate_UpdationMail(UserReportRepository.GetFnameByEmail(toMail), subject, sb.ToString(), toMail);
                }
            }
            return(res);
        }
Exemplo n.º 5
0
        public static dynamic UpdateTicket(Mst_Task objupdateTask)
        {
            CustomResponse objres = new CustomResponse();

            try
            {
                using (var objcontext = new Db_Zon_Test_techsupportEntities())
                {
                    // get short name of the project and get the max count of the tickets and use it as display name
                    int      tid     = objupdateTask.ID;;
                    Mst_Task objtask = objcontext.Mst_Task.Where(x => x.ID == tid).FirstOrDefault();

                    objtask.Title         = objupdateTask.Title;
                    objtask.Description   = objupdateTask.Description;
                    objtask.AssigndedDate = objupdateTask.AssigndedDate;
                    objtask.DueDate       = objupdateTask.DueDate;
                    objtask.AssignedTo    = objupdateTask.AssignedTo;
                    objtask.RefereedTo    = objupdateTask.RefereedTo;
                    objtask.Task_Status   = objupdateTask.Task_Status;
                    objtask.TypeID        = objupdateTask.TypeID;
                    objtask.ProjectID     = objupdateTask.ProjectID;
                    objtask.PriorityID    = objupdateTask.PriorityID;
                    objcontext.SaveChanges();
                    objres.Message  = "Success";
                    objres.Response = objupdateTask;
                    objres.Status   = CustomResponseStatus.Successful;
                    return(objres);
                }
            }
            catch (Exception ex)
            {
                objres.Message  = ex.Message;
                objres.Response = null;
                objres.Status   = CustomResponseStatus.UnSuccessful;
                return(objres);
            }
        }