Esempio n. 1
0
        public JsonResult ReplyTicket(TicketReplyViewModel ticketReplyViewModel)
        {
            if (ticketReplyViewModel.LeaveApprovedFrom != null && ticketReplyViewModel.LeaveApprovedTo != null)
            {
                ticketReplyViewModel.LeaveApprovedBy   = (int)Session["EmployeeID"];
                ticketReplyViewModel.LeaveApprovedDate = DateTime.UtcNow;
            }
            ticketReplyViewModel.TicketRepliedBy = User.Identity.GetUserId();
            TicketReplyResponse ticketReplyResponse = ticketReplyViewModel.MapReplyFromClientToServer();
            bool replyConfirmation = ticketService.ReplyTicket(ticketReplyResponse);

            ticketReplyViewModel.replyConfirmationStatus = replyConfirmation;

            return(Json(ticketReplyViewModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
 public static TicketReplyResponse MapReplyFromClientToServer(this TicketReplyViewModel source)
 {
     return(new TicketReplyResponse
     {
         TicketId = source.TicketId,
         TicketRepliedBy = source.TicketRepliedBy,
         TicketReply = source.TicketReply,
         Status = source.Status,
         LeaveApprovedBy = source.LeaveApprovedBy,
         LeaveApprovedDate = source.LeaveApprovedDate,
         LeaveApprovedFrom = source.LeaveApprovedFrom,
         LeaveApprovedTo = source.LeaveApprovedTo,
         WorkingDays = source.WorkingDays
     });
 }
Esempio n. 3
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;
            }
        }