public ActionResult Create(AssignedJobsCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateAssignedJobService(); if (service.CreateAssignedJobs(model)) { TempData["SaveResult"] = "Your assignment was created."; return(RedirectToAction("Index")); } ; return(View(model)); }
public bool CreateAssignedJobs(AssignedJobsCreate model) { var entity = new AssignedJobs() { OwnerId = _userId, JobId = model.JobId, TitleOfJob = model.TitleOfJob, EquipmentAvailable = model.EquipmentAvailable, WorkerId = model.WorkerId, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Assignments.Add(entity); return(ctx.SaveChanges() == 1); } }