public async Task <ActionResult> AssignTicket(int tickets, string AssignedToUserId)
        {
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == tickets);
            var ticket    = db.Tickets.Find(tickets);

            ticket.AssignedToUserId = AssignedToUserId;
            db.SaveChanges();
            var newTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == tickets);

            notifyHelp.ManageNotifications(oldTicket, newTicket);
            var callbackUrl = Url.Action("Details", "Tickets", new { id = ticket.Id },
                                         protocol: Request.Url.Scheme);

            try
            {
                EmailService    ems  = new EmailService();
                IdentityMessage msg  = new IdentityMessage();
                ApplicationUser user = db.Users.Find(ticket.AssignedToUserId);
                msg.Body = "You have been assigned a new Ticket." + Environment.NewLine +
                           "Please click the following link to view the details  " +
                           "<a href=\"" + callbackUrl + "\">NEW TICKET</a>";
                msg.Destination = user.Email;
                msg.Subject     = "New Ticket Assignment";
                await ems.SendMailAsync(msg);
            }
            catch (Exception ex)
            {
                await Task.FromResult(0);
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "Id,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId,Title,Description,Created,Updated")] Tickets ticket, string developer)
        {
            if (ModelState.IsValid)
            {
                var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);

                ticket.Updated = DateTime.Now;
                if (developer != null)
                {
                    ticket.AssignedToUserId = developer;
                }
                db.Entry(ticket).State = EntityState.Modified;
                db.SaveChanges();

                var newTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);
                hisHelper.RecordHistoricalChanges(oldTicket, newTicket);
                notHelper.ManageNotifications(oldTicket, newTicket);


                return(RedirectToAction("Details", new { id = ticket.Id }));
            }
            var devs = roleHelper.UsersInRole("Developer").ToList();

            //ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FName", ticket.AssignedToUserId);
            ViewBag.Developer        = new SelectList(devs, "Id", "FName", ticket.AssignedToUserId);
            ViewBag.OwnerUserId      = new SelectList(db.Users, "Id", "FName", ticket.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatus, "Id", "Name", ticket.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId);

            return(View(ticket));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "TransactionTypeId,BankAccountId,CategoryItemId,Amount,Memo")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.Created = DateTime.Now;
                transaction.OwnerId = User.Identity.GetUserId();

                db.Transactions.Add(transaction);


                //Do I need to update or adjust the associated bank account balance... yes
                var bank      = db.BankAccounts.Find(transaction.BankAccountId);
                var transType = db.TransactionTypes.Find(transaction.TransactionTypeId).Type;

                if (transType == "Deposit")
                {
                    bank.CurrentBalance += transaction.Amount;
                }
                else
                {
                    bank.CurrentBalance -= transaction.Amount;
                }


                db.SaveChanges();

                notificationHelper.ManageNotifications(bank, transaction);
                return(RedirectToAction("Index"));
            }

            ViewBag.BankAccountId     = new SelectList(db.BankAccounts, "Id", "OwnerId", transaction.BankAccountId);
            ViewBag.CategoryItemId    = new SelectList(db.CategoryItems, "Id", "Name", transaction.CategoryItemId);
            ViewBag.OwnerId           = new SelectList(db.Users, "Id", "Email", transaction.OwnerId);
            ViewBag.TransactionTypeId = new SelectList(db.TransactionTypes, "Id", "Type", transaction.TransactionTypeId);
            return(View(transaction));
        }