예제 #1
0
        public ActionResult Details(TicketReplyModel ticketReplyModel, string resolved, string inprogress, string onHold, string replied)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var file     = Request.Files;
                    var statusId = 0;

                    if (!string.IsNullOrEmpty(resolved))
                    {
                        statusId = (int)StatusMain.Status.Resolved;
                    }
                    else if (!string.IsNullOrEmpty(inprogress))
                    {
                        statusId = (int)StatusMain.Status.InProgress;
                    }
                    else if (!string.IsNullOrEmpty(onHold))
                    {
                        statusId = (int)StatusMain.Status.OnHold;
                    }
                    else if (!string.IsNullOrEmpty(replied))
                    {
                        statusId = (int)StatusMain.Status.Replied;
                    }

                    ReplyAttachment        replyAttachment        = new ReplyAttachment();
                    ReplyAttachmentDetails replyAttachmentDetails = new ReplyAttachmentDetails();

                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <ReplyAttachment>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <ReplyAttachmentDetails>();

                    for (int i = 0; i <= file.Count - 1; i++)
                    {
                        if (file[i] != null && file[i].ContentLength > 0)
                        {
                            string extension = Path.GetExtension(file[i].FileName);
                            replyAttachment.SystemUser     = Convert.ToInt64(_sessionHandler.UserId);
                            replyAttachment.AttachmentName = file[i].FileName;
                            replyAttachment.AttachmentType = extension;
                            replyAttachment.CreatedDate    = DateTime.Now;
                            var inputStream = file[i].InputStream;
                            if (inputStream != null)
                            {
                                using (var binaryReader = new BinaryReader(inputStream))
                                {
                                    byte[] fileSize = binaryReader.ReadBytes(count: file[i].ContentLength);
                                    replyAttachmentDetails.AttachmentBytes = fileSize;
                                }
                            }

                            listofattachments.Add(replyAttachment);
                            listofattachmentdetails.Add(replyAttachmentDetails);
                        }
                    }


                    var userId = Convert.ToInt64(_sessionHandler.UserId);

                    var message = AppendString(ticketReplyModel.Message);
                    ticketReplyModel.Message = message;

                    _ticketsReply.ReplyTicket(ticketReplyModel, listofattachments, listofattachmentdetails, null, userId, statusId);

                    var ticket = _displayTickets.TicketsDetailsbyticketId(ticketReplyModel.TrackingId);
                    ticket.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    ticket.ListofStatus   = _status.GetAllStatusWithoutOverdueandEscalationSelectListItem();
                    ticket.TicketReply    = new TicketReplyModel()
                    {
                        Message    = string.Empty,
                        TicketId   = ticket.TicketId,
                        TrackingId = ticket.TrackingId
                    };

                    var listofTicketreply = _ticketsReply.ListofHistoryTicketReplies(ticketReplyModel.TrackingId);

                    if (listofTicketreply != null)
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId);
                        ticket.ViewMainModel     = new ViewTicketReplyMainModel()
                        {
                            ListofReplyAttachment = _attachments.GetListReplyAttachmentsByAttachmentId(ticketReplyModel.TicketId)
                        };
                    }
                    else
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofTicketreply     = new List <ViewTicketReplyHistoryModel>(),
                            ListofReplyAttachment = new List <ReplyAttachment>()
                        };
                    }

                    TicketHistory(ticketReplyModel, resolved, inprogress, onHold, replied);
                    TempData["TicketReplyMessage"] = CommonMessages.TicketSuccessReplyMessages;

                    return(RedirectToAction("Details", "TicketDetailsAdmin", new { trackingId = ticket.TrackingId }));
                }
                else
                {
                    var ticket = _displayTickets.TicketsDetailsbyticketId(ticketReplyModel.TrackingId);
                    ticket.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    ticket.ListofStatus   = _status.GetAllStatusWithoutOverdueandEscalationSelectListItem();
                    ticket.EscalatedUser  = _userMaster.GetTicketEscalatedToUserNames(ticket.TicketId);
                    ticket.ListofCategory = _category.GetAllActiveSelectListItemCategory();

                    ticket.TicketReply = new TicketReplyModel()
                    {
                        Message    = string.Empty,
                        TicketId   = ticket.TicketId,
                        TrackingId = ticket.TrackingId
                    };
                    var listofTicketreply = _ticketsReply.ListofHistoryTicketReplies(ticketReplyModel.TrackingId);

                    if (listofTicketreply.Count > 0)
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofReplyAttachment = _attachments.GetListReplyAttachmentsByAttachmentId(ticketReplyModel.TicketId),
                            ListofTicketreply     = listofTicketreply
                        };
                    }
                    else
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofTicketreply     = new List <ViewTicketReplyHistoryModel>(),
                            ListofReplyAttachment = new List <ReplyAttachment>()
                        };
                    }

                    TempData["TicketReplyMessage"] = CommonMessages.TicketErrorReplyMessages;
                    return(View(ticket));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public ActionResult EditReply(TicketReplyViewModel ticketReplyViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int result;
                    var decodemessage = DecodeHtml(ticketReplyViewModel.Message);
                    ticketReplyViewModel.Message = decodemessage;

                    var                    file                   = Request.Files;
                    ReplyAttachment        replyAttachment        = new ReplyAttachment();
                    ReplyAttachmentDetails replyAttachmentDetails = new ReplyAttachmentDetails();

                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <ReplyAttachment>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <ReplyAttachmentDetails>();

                    if (file.Count > 0)
                    {
                        if (Request.Files["fileupload_1"].ContentLength != 0 ||
                            Request.Files["fileupload_2"].ContentLength != 0 ||
                            Request.Files["fileupload_3"].ContentLength != 0)
                        {
                            for (int i = 0; i <= file.Count - 1; i++)
                            {
                                if (file[i] != null && file[i].ContentLength > 0)
                                {
                                    string extension = Path.GetExtension(file[i].FileName);
                                    replyAttachment.SystemUser     = Convert.ToInt64(_sessionHandler.UserId);
                                    replyAttachment.AttachmentName = file[i].FileName;
                                    replyAttachment.AttachmentType = extension;
                                    replyAttachment.CreatedDate    = DateTime.Now;
                                    var inputStream = file[i].InputStream;
                                    if (inputStream != null)
                                    {
                                        using (var binaryReader = new BinaryReader(inputStream))
                                        {
                                            byte[] fileSize = binaryReader.ReadBytes(count: file[i].ContentLength);
                                            replyAttachmentDetails.AttachmentBytes = fileSize;
                                        }
                                    }

                                    listofattachments.Add(replyAttachment);
                                    listofattachmentdetails.Add(replyAttachmentDetails);
                                }
                            }

                            result = _tickets.UpdateTicketReply(ticketReplyViewModel, listofattachments,
                                                                listofattachmentdetails, null, Convert.ToInt32(_sessionHandler.UserId));
                        }

                        else
                        {
                            result = _tickets.UpdateTicketReply(ticketReplyViewModel, null, null,
                                                                null, Convert.ToInt32(_sessionHandler.UserId));
                        }
                    }
                    else
                    {
                        result = _tickets.UpdateTicketReply(ticketReplyViewModel, null, null,
                                                            null, Convert.ToInt32(_sessionHandler.UserId));
                    }

                    TicketHistoryHelper ticketHistoryHelper = new TicketHistoryHelper();
                    TicketHistory       ticketHistory       = new TicketHistory
                    {
                        UserId       = Convert.ToInt32(_sessionHandler.UserId),
                        Message      = ticketHistoryHelper.EditReplyTicket(),
                        ProcessDate  = DateTime.Now,
                        TicketId     = ticketReplyViewModel.TicketId,
                        ActivitiesId = Convert.ToInt16(StatusMain.Activities.EditedTicketReply)
                    };
                    _ticketHistory.TicketHistory(ticketHistory);

                    if (result > 0)
                    {
                        TempData["TicketReplyMessage"] = CommonMessages.TicketUpdatedSuccessReplyMessages;
                    }
                    return(RedirectToAction("Details", "TicketDetailsHOD", new { trackingId = ticketReplyViewModel.TrackingId }));
                }
                else
                {
                    var ticketsViewModel = _tickets.EditTicketsByTicketReplyId(ticketReplyViewModel.TrackingId, ticketReplyViewModel.TicketReplyId);
                    return(View(ticketsViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }