public ActionResult Create() { ScheduleEdit se = new ScheduleEdit(); se.Staffs = db.Staffs.ToList(); return(View(se)); }
//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); }
public ActionResult Edit(int id) { ScheduleEdit scheduleeditview = new ScheduleEdit(); //Finds all staffs scheduleeditview.Staffs = db.Staffs.ToList(); //finds all schedules scheduleeditview.Schedules = db.Schedules.Include(sc => sc.Staff).SingleOrDefault(s => s.ScheduleId == id); //GOTO: Views/Staff/Edit.cshtml return(View(scheduleeditview)); }
public ActionResult CreateSchedulePartial(ScheduleEdit model) { if (ModelState.IsValid) { var repo = new JobRepository(); var updatedModel = repo.SaveSchedule(model); if (updatedModel != null) { return(RedirectToAction("Edit", new { id = model.JobId })); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public ScheduleEdit SaveSchedule(ScheduleEdit model) { //if (model != null && string.IsNullOrEmpty(model.JobId) ) if (model != null && Guid.TryParse(model.Id.ToString(), out Guid jobid)) { using (var context = new CBDBEntities()) { //if (string.IsNullOrEmpty(jobedit.Id)) //{ var schedule = new Models.Schedule() { //Id = newGuid.ToString(), //Id = customerid, // JobId = model.JobId, JobId = jobid.ToString(), text = model.text, start_date = model.start_date, end_date = model.end_date, //statusId = model.SelectedStatus, SchTypeId = model.SelectedSchType }; schedule.SchType = context.SchTypes.Find(schedule.SchTypeId); //schedule.ScheduleStatu = context.ScheduleStatus.Find(schedule.statusId); context.Schedules.Add(schedule); context.SaveChanges(); var schTypesRepo = new SchTypeRepository(); model.SchType = schTypesRepo.GetSchTypes(); var schStatuRepo = new ScheduleStatuRepository(); //model.ScheduleStatu = schStatuRepo.GetScheduleStatus(); return(model); } } // Return false if customeredit == null or CustomerID is not a guid return(null); }
public ActionResult BookingTypePartial(Models.ViewModels.BookingType model) { if (ModelState.IsValid && !String.IsNullOrWhiteSpace(model.JobId)) { switch (model.SelectedBookingType) { case "Schedule": var scheduleModel = new ScheduleEdit() // var scheduleModel = new Schedule() { JobId = model.JobId }; return(PartialView("CreateSchedulePartial", scheduleModel)); case "Crew": var crewModel = new CrewEdit() // var crewModel = new Crew() { JobId = model.JobId }; return(PartialView("CreateCrewPartial", crewModel)); //case "BookingFleet": // var fleetModel = new BookingFleet() // { // JobId = model.JobId // }; // return PartialView("CreateBookingFleetPartial", fleetModel); // case "BookingHotel": // var hotelModel = new BookingHotel() // { // JobId = model.JobId // }; // return PartialView("CreateBookingHotelPartial", hotelModel); // case "BookingKit": // var kitModel = new BookingKit() // { // JobId = model.JobId // }; // return PartialView("CreateBookingKitPartial", kitModel); // case "BookingEquipment": // var equipmentModel = new BookingEquipment() // { // JobId = model.JobId // }; // //var countriesRepo = new CountriesRepository(); // //postalAddressModel.Countries = countriesRepo.GetCountries(); // //var regionsRepo = new RegionsRepository(); // //postalAddressModel.Regions = regionsRepo.GetRegions(); // return PartialView("CreateBookingPartial", equipmentModel); default: return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
/// <summary> /// Called when [saved]. /// </summary> /// <param name="schedule">The schedule.</param> public void OnSaved(ScheduleEdit schedule) { Model = schedule; }
/// <summary> /// Initializes the specified schedule. /// </summary> /// <param name="schedule">The schedule.</param> public void Initialize(ScheduleEdit schedule) { Model = schedule; }