public JsonResult Save(Models.DTO.Schedule record) { Schedule entity; using (CBDBEntities context = new CBDBEntities()) { if (record.Id == 0) { entity = context.Schedules.First(p => p.Id == record.Id); entity.text = record.text; //entity.SchTypeId = record.SchTypeId; //entity.Country = context.Locations.FirstOrDefault(l => l.ID == record.CountryID); // entity.statusId = record.statusId; // entity.JobId = record.JobId; entity.start_date = record.start_date; entity.end_date = record.end_date; } else { context.Schedules.Add(new Schedule { Id = record.Id, text = record.text, //statusId = record.statusId, // JobId = record.JobId, // SchTypeId = record.SchTypeId, start_date = record.start_date, end_date = record.end_date, }); } context.SaveChanges(); } return(Json(new { result = true })); }
//START SECOND //public List<Models.DTO.Schedule> GetSchedule(string jobid, int scheduleid) public Models.DTO.Schedule GetSchedule(string jobid, int scheduleid) { if (jobid != string.Empty) { using (var context = new CBDBEntities()) { var schedule = context.Schedules.AsNoTracking() .Where(x => x.JobId == jobid && x.Id == scheduleid) .Single(); if (schedule != null) { var scheduleVm = new Models.DTO.Schedule() { JobId = schedule.JobId, text = schedule.text?.Trim(), start_date = schedule.start_date, end_date = schedule.end_date, }; //var schTypesRepo = new SchTypeRepository(); //scheduleVm.SchTypName = schTypesRepo.GetSchTypeName(schedule.SchTypeId); //var jobStatuRepo = new JobStatuRepository(); //scheduleVm.StatusName = jobStatuRepo.GetJobStatuName(schedule.statusId); var schTypesRepo = new SchTypeRepository(); scheduleVm.SchTypName = schTypesRepo.GetSchTypes().ToString(); var schStatuRepo = new ScheduleStatuRepository(); //scheduleVm.StatusName = schStatuRepo.GetScheduleStatus().ToString(); //var schTypesRepo = new SchTypeRepository(); //scheduleVm.SchTypName = schTypesRepo.GetSchTypes().ToString(); //var scheduleStatuRepo = new ScheduleStatuRepository(); //scheduleVm.StatusName = scheduleStatuRepo.GetScheduleStatus().ToString(); return(scheduleVm); } } } return(null); }
// START SCHEDULE LIST // public List<Models.DTO.ScheduleListView> GetScheduleList(string jobid) public Models.DTO.ScheduleListView GetScheduleList(string jobid) { if (jobid != string.Empty) { using (var context = new CBDBEntities()) { var schedules = context.Schedules.AsNoTracking() .Where(x => x.JobId == jobid) .OrderBy(x => x.Id); if (schedules != null) { var scheduleListView = new ScheduleListView(); foreach (var schedule in schedules) { var scheduleVm = new Models.DTO.Schedule() { JobId = schedule.JobId.ToString(), Id = schedule.Id, text = schedule.text, //SchTypeId = schedule.SchTypeId, //SchTypName = schedule.SchType.name, start_date = schedule.start_date, end_date = schedule.end_date, //StatusName = schedule.ScheduleStatu.title }; //var schTypesRepo = new SchTypeRepository(); //scheduleVm.SchTypName = schTypesRepo.GetSchTypeName(schedule.SchTypeId); //var jobStatuRepo = new JobStatuRepository(); //scheduleVm.StatusName = jobStatuRepo.GetJobStatuName(schedule.statusId); //scheduleListView.Schedules.Add(scheduleVm); var schTypesRepo = new SchTypeRepository(); scheduleVm.SchTypName = schTypesRepo.GetSchTypes().ToString(); var schStatuRepo = new ScheduleStatuRepository(); //scheduleVm.StatusName = schStatuRepo.GetScheduleStatus().ToString(); scheduleListView.Schedules.Add(scheduleVm); } return(scheduleListView); } } } return(null); }
public ActionResult BookingTypePartial(Models.DTO.BookingType model) { if (ModelState.IsValid && !String.IsNullOrWhiteSpace(model.JobId)) { switch (model.SelectedBookingType) { case "Schedule": var scheduleModel = new Models.DTO.Schedule() { JobId = model.JobId }; return(PartialView("CreateSchedulePartial", scheduleModel)); case "Crew": var crewModel = new Models.DTO.Crew() { JobId = model.JobId }; return(PartialView("CreateCrewPartial", crewModel)); case "BookinFleet": var fleetModel = new Models.DTO.BookingFleet() { JobId = model.JobId }; //var fleetTypeRepo = new FleetTypeRepository(); //fleetModel. = fleetTypeRepo.GetFleetTypes(); //var regionsRepo = new RegionsRepository(); //postalAddressModel.Regions = regionsRepo.GetRegions(); return(PartialView("CreateBookingFleetPartial", fleetModel)); case "BookingHotel": var hotelModel = new Models.DTO.BookingHotel() { JobId = model.JobId }; //var countriesRepo = new CountriesRepository(); //postalAddressModel.Countries = countriesRepo.GetCountries(); //var regionsRepo = new RegionsRepository(); //postalAddressModel.Regions = regionsRepo.GetRegions(); return(PartialView("CreateBookingHotelPartial", hotelModel)); case "BookingKit": var kitModel = new Models.DTO.BookingKit() { JobId = model.JobId }; //var countriesRepo = new CountriesRepository(); //postalAddressModel.Countries = countriesRepo.GetCountries(); //var regionsRepo = new RegionsRepository(); //postalAddressModel.Regions = regionsRepo.GetRegions(); return(PartialView("CreateBookingKitPartial", kitModel)); case "BookingEquipment": var equipmentModel = new Models.DTO.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)); }