//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 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); }