Example #1
0
        public ActionResult Edit(Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                if(ticket.Id==0)
                {
                    ticket.Created = DateTime.Now;
                }
                ActionConfirmation<Ticket> confirmation = ticketMgmtTasks.SaveOrUpdate(ticket);

                if (confirmation.WasSuccessful)
                {
                    TempData["message"] = confirmation.Message;
                    return RedirectToAction("Index");
                }

                ViewData["message"] = confirmation.Message;
            }

            return View(ticketMgmtTasks.CreateEditViewModel(ticket));
        }
Example #2
0
        public void CanSaveAssignationWithPersonAndTicket()
        {
            var person = new Person();
            person.BirthDate=new DateTime(2000,1,1);
            person.FirstName = "John";
            person.LastName = "Smith";
            var session = _sessionFactory.OpenSession();

            var ticket = new Ticket();
            ticket.Created=DateTime.Now;
            ticket.Description = "First ticket";
            ticket.Title = "Title";
            ticket.TicketStatus = TicketStatusType.New;
            var assignation = new TicetPersonAssignation() {AssignationStart = DateTime.Now, Assigned = person};
            assignation.Ticket = ticket;

            using (var t=session.BeginTransaction())
            {
                //session.SaveOrUpdate(person);
                //session.SaveOrUpdate(ticket);
                session.SaveOrUpdate(assignation);
                t.Commit();
            }
        }