public void InsertOrUpdate(ServiceLogEntry servicelogentry)
 {
     if (servicelogentry.ID == default(int))
     {
         this.context.ServiceLogEntries.Add(servicelogentry);
     }
     else
     {
         this.context.Entry(servicelogentry).State = EntityState.Modified;
     }
 }
        public ActionResult Create(ServiceTicket serviceticket)
        {
            if (ModelState.IsValid)
            {
                serviceticket.Opened = DateTime.Now;

                var createdBy = this.employeeRepository.All.Where(e => e.Identity == "NORTHAMERICA\\drobbins").FirstOrDefault();

                if (createdBy != null)
                    serviceticket.CreatedByID = createdBy.ID;

                var serviceLogEntry = new ServiceLogEntry
                {
                    ServiceTicket = serviceticket,
                    CreatedAt = DateTime.Now,
                    CreatedBy = serviceticket.CreatedBy,
                    CreatedByID = serviceticket.CreatedByID,
                    Description = "Created",
                };

                this.serviceLogEntryRepository.InsertOrUpdate(serviceLogEntry);
                this.serviceLogEntryRepository.Save();

                return RedirectToAction("Details", new { serviceticket.ID });
            }
            else
            {
                ViewBag.PossibleCustomers = this.customerRepository.All;
                ViewBag.PossibleCreatedBies = this.employeeRepository.All;
                ViewBag.PossibleAssignedToes = this.employeeRepository.All;
                ViewBag.PossibleEscalationLevels = new Dictionary<string, string> { { "1", "Level 1" }, { "2", "Level 2" }, { "3", "Level 3" } };

                var newTicket = new ServiceTicket
                {
                    CreatedBy = this.employeeRepository.All.Where(e => e.Identity == "NORTHAMERICA\\drobbins").FirstOrDefault(),
                };

                return View(newTicket);
            }
        }