Exemple #1
0
        public IActionResult Booking(Guid id)
        {
            var item   = Service.GetById(id);
            var Ticket = _ticket.GetAll().Where(x => x.ClaimId.Equals(id)).FirstOrDefault();

            if (item != null)
            {
                ViewBag.TicketId       = Ticket.Id;
                ViewBag.Travel         = item;
                ViewBag.RequestBy      = _userHelper.GetLoginUser(User).Name;
                ViewBag.Departure      = _city.GetById(item.DepartureId).Name;
                ViewBag.Destination    = _city.GetById(item.DestinationId).Name;
                ViewBag.ProjectManager = _profileUser.GetById(item.ClaimApproverOneId).Name;
                ViewBag.LineManager    = _profileUser.GetById(item.ClaimApproverTwoId).Name;
                ViewBag.TicketInfo     = Enum.GetValues(typeof(TicketInfoStatus)).Cast <TicketInfoStatus>().Select(v => new SelectListItem
                {
                    Text  = Extension.GetEnumDescription(v),
                    Value = ((int)v).ToString()
                }).ToList();
                TicketInfoFormModel model = Mapper.Map <TicketInfoFormModel>(Ticket);
                if (!string.IsNullOrWhiteSpace(Ticket.Files))
                {
                    var attachments = JsonConvert.DeserializeObject <List <string> >(Ticket.Files);
                    model.Files   = string.Join("|", attachments.ToArray()) + "|";
                    ViewBag.Files = attachments;
                }
                else
                {
                    ViewBag.Files = null;
                }
                return(View(model));
            }
            return(NotFound());
        }
Exemple #2
0
        public IActionResult Booking(Guid id, TicketInfoFormModel model)
        {
            if (ModelState.IsValid)
            {
                var Ticket = _ticket.GetAll().Where(x => x.ClaimId.Equals(id)).FirstOrDefault();
                Ticket.Note        = model.Description;
                Ticket.Price       = model.Price;
                Ticket.Description = model.Description;
                Ticket.Status      = model.Status;
                _ticket.Update(Ticket);

                // Send Notif To Contractor if ticket exists
                if (!string.IsNullOrEmpty(Ticket.Files))
                {
                    var Travel         = Service.GetById(Ticket.ClaimId);
                    var Contractor     = _userHelper.GetUserProfile(Travel.ContractorId.Value);
                    var UserContractor = _userHelper.GetUser(Contractor.ApplicationUserId);
                    if (UserContractor != null)
                    {
                        var callbackUrl = Url.Action("Index",
                                                     "Travel",
                                                     new { area = "Admin" },
                                                     _hostConfiguration.Protocol,
                                                     _hostConfiguration.Name);


                        _notif.Send(
                            User,                                          // User From
                            "Booked Ticket",                               // Subject
                            Contractor.Name,                               // User target name
                            UserContractor.Email,                          // User target email
                            callbackUrl,                                   // Link CallBack
                            " Your Ticket is issued as for below Thanks ", // Email content or descriptions
                            model.Description,                             // Description
                            NotificationInboxStatus.Request,               // Notif Status
                            Activities.Travel,                             // Activity Status,
                            Ticket.Files
                            );
                    }
                }


                TempData["success"] = "OK";
                return(RedirectToAction("Booking", new { id = id }));
            }
            return(NotFound());
        }