public ActionResult Create(JobModelView model) { if (ModelState.IsValid) { var job = new JOB() { ID = Guid.NewGuid(), Description = model.Description, Cost = model.Cost, JobTypeID = model.JobTypeID, CustomerID = model.CustomerID, CreationDate = DateTime.Now, CreatedBy = User.Identity.Name, LastModifiedBy = User.Identity.Name }; try { db.JOBs.Add(job); db.SaveChanges(); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Jobs", "Index"))); } return(RedirectToAction("Index")); } // Something failed, return return(View(model)); }
// GET: Jobs/ public ActionResult Create() { JobModelView JMV = new JobModelView(); JobManager jm = new JobManager(); JMV.JobCustomer = new JobCustomer(); JMV.JobCustomer.Customer = jm.GetAllCustomers(); JMV.JobType = jm.GetAllJobTypes(); return(View(JMV)); }
public void AddJob(JobModelView user) { using (SchedulerEntities db = new SchedulerEntities()) { JOB SU = new JOB(); SU.ID = user.ID; SU.JobTypeID = user.JobTypeID; SU.CreatedBy = HttpContext.Current.User.Identity.Name; SU.LastModifiedBy = HttpContext.Current.User.Identity.Name; SU.CreationDate = DateTime.Now; SU.Description = user.Description; SU.CustomerID = user.CustomerID; SU.Cost = user.Cost; db.SaveChanges(); } }