public ActionResult Create([Bind(Include = "Id,JobId,text,start_date,end_date,SchType")] Schedule schedule) { if (ModelState.IsValid) { db.Schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.JobId = new SelectList(db.Jobs, "JobId", "JobRef", schedule.JobId); return(View(schedule)); }
//execute save public ScheduleEdit SaveSchedule(ScheduleEdit model) { if (model != null && Guid.TryParse(model.JobId, out Guid jobid)) { using (var context = new CloudbassContext()) { var schedule = new Models.Schedule() { JobId = jobid, text = model.text?.Trim(), start_date = model.start_date, end_date = model.end_date, SchType = model.SchType }; context.Schedules.Add(schedule); context.SaveChanges(); return(model); } } // Return false if customeredit == null or CustomerID is not a guid return(null); }
//Save Crew public CrewEdit SaveCrew(CrewEdit model) { if (model != null && Guid.TryParse(model.JobId, out Guid jobid)) { using (var context = new CloudbassContext()) { var crew = new Models.Crew() { JobId = jobid, has_RoleId = model.has_RoleId, start_date = model.start_date, end_date = model.end_date, totalDays = model.totalDays, }; context.Crews.Add(crew); context.SaveChanges(); return(model); } } // Return false if customeredit == null or CustomerID is not a guid return(null); }
public bool SaveJob(JobEdit jobedit) { if (jobedit != null) { using (var context = new CloudbassContext()) { if (Guid.TryParse(jobedit.JobId, out Guid newGuid)) { var job = new Models.Jobs() { JobId = newGuid, text = jobedit.text, Description = jobedit.Description, Location = jobedit.Location, Coordinator = jobedit.Coordinator, DateCreated = jobedit.DateCreated, //NameConcatenateLocation = jobEdit.Name, start_date = jobedit.start_date, TXDate = jobedit.TXDate, end_date = jobedit.end_date, ClientId = jobedit.SelectedClientId, // statusId = jobedit.SelectedStatus, CommercialLead = jobedit.CommercialLead, // JobRef = jobedit.JobRef, Status = jobedit.Status }; job.Client = context.Clients.Find(jobedit.SelectedClientId); //job.JobStatu = context.JobStatus.Find(jobedit.SelectedStatus); context.Jobs.Add(job); context.SaveChanges(); return(true); } } } // Return false if customeredit == null or CustomerID is not a guid return(false); }