public async Task <ActionResult> Query(ScheduleQueryViewModel model) { if (ModelState.IsValid) { using (ScheduleServiceClient client = new ScheduleServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /FMM/Schedule/Detail public async Task <ActionResult> Detail(string key) { using (ScheduleServiceClient client = new ScheduleServiceClient()) { MethodReturnResult <Schedule> result = await client.GetAsync(key); if (result.Code == 0) { ScheduleViewModel viewModel = new ScheduleViewModel() { Name = result.Data.Key, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Description = result.Data.Description, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
public void Step2_API_MakeFlights() { Simulate simulate = new Simulate(); WebClient client = new WebClient(); // make flights ScheduleServiceClient scheduleService = new ScheduleServiceClient(); scheduleService.MakeFlightsFromScheduleAll(DefaultUserId); }
// GET: Schedule public ActionResult MakeFlightsFromSchedule(Guid flightScheduleId) { var schedule = new ScheduleServiceClient(); schedule.MakeFlightsFromSchedule( flightScheduleId, DefaultUserId ); return(RedirectToAction("FlightsForPeriodIndex", "FlightsForPeriodLive")); }
public void GetSchedulesByDepartmentIdAndDateTest() { ScheduleServiceClient client = new ScheduleServiceClient(); Schedule schedule = client.GetScheduleByDepartmentIdAndDate(1, new DateTime(2017, 11, 15)); Assert.IsNotNull(schedule); Assert.AreEqual(new DateTime(2017, 11, 01), schedule.StartDate); Assert.AreNotEqual(0, schedule.Shifts.Count); Assert.AreEqual("Kolonial", schedule.Department.Name); }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (ScheduleServiceClient client = new ScheduleServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.Schedule_Delete_Success , key); } return(Json(result)); } }
public ActionResult ScheduleEdit(System.Guid flightScheduleId) { ScheduleContract scheduleContract = new ScheduleServiceClient().GetSchedule( flightScheduleId, DefaultUserId ); ViewBag.AirlineId = new SelectList(new CrudeAirlineServiceClient().FetchAll(), "AirlineId", "AirlineName", scheduleContract.FlightSchedule.AirlineId ); // items, string dataValueField, string dataTextField, string dataGroupField, object selectedValue ViewBag.AircraftTypeRcd = new SelectList(items: new CrudeAircraftTypeRefServiceClient().FetchAll(), dataValueField: "AircraftTypeRcd", dataTextField: "AircraftTypeName", selectedValue: scheduleContract.FlightSchedule.AircraftTypeRcd ); ViewBag.DepartureAirportId = new SelectList(new CrudeAirportServiceClient().FetchAll(), "AirportId", "AirportName", scheduleContract.FlightSchedule.DepartureAirportId ); ViewBag.ArrivalAirportId = new SelectList(new CrudeAirportServiceClient().FetchAll(), "AirportId", "AirportName", scheduleContract.FlightSchedule.ArrivalAirportId ); ViewBag.DefaultUserName = new CrudeDefaultUserServiceClient().FetchByDefaultUserId( scheduleContract.FlightSchedule.UserId ).DefaultUserName; return(View( MVCHelper.Resolve(Request, "Schedule", "ScheduleEdit"), scheduleContract )); }
public void Step3_API_CheckFlightAndMakeBookings() { Simulate simulate = new Simulate(); WebClient client = new WebClient(); ScheduleServiceClient scheduleService = new ScheduleServiceClient(); // flight status for (int i = 0; i < 10; i++) { simulate.CheckFlightStatuses(); } // bookings for (int i = 0; i < 10; i++) { simulate.SimulateBookings(); } }
// // GET: /FMM/Schedule/ public async Task <ActionResult> Index() { using (ScheduleServiceClient client = new ScheduleServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "Key" }; MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new ScheduleQueryViewModel())); }
public IEnumerable <SelectListItem> GetScheduleName() { using (ScheduleServiceClient client = new ScheduleServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg); if (result.Code <= 0) { IEnumerable <SelectListItem> lst = from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }; return(lst); } } return(new List <SelectListItem>()); }
public async Task <ActionResult> SaveModify(ScheduleViewModel model) { using (ScheduleServiceClient client = new ScheduleServiceClient()) { MethodReturnResult <Schedule> result = await client.GetAsync(model.Name); if (result.Code == 0) { result.Data.Description = model.Description; result.Data.Editor = User.Identity.Name; result.Data.EditTime = DateTime.Now; MethodReturnResult rst = await client.ModifyAsync(result.Data); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.Schedule_SaveModify_Success , model.Name); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Save(ScheduleViewModel model) { using (ScheduleServiceClient client = new ScheduleServiceClient()) { Schedule obj = new Schedule() { Key = model.Name, Description = model.Description, Editor = User.Identity.Name, EditTime = DateTime.Now, CreateTime = DateTime.Now, Creator = User.Identity.Name }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.Schedule_Save_Success , model.Name); } return(Json(rst)); } }
public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (ScheduleServiceClient client = new ScheduleServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }
// // GET: /FMM/ScheduleDetail/ public async Task <ActionResult> Index(string scheduleName) { using (ScheduleServiceClient client = new ScheduleServiceClient()) { MethodReturnResult <Schedule> result = await client.GetAsync(scheduleName ?? string.Empty); if (result.Code > 0 || result.Data == null) { return(RedirectToAction("Index", "Schedule")); } ViewBag.Schedule = result.Data; } using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { Where = string.Format(" Key.ScheduleName = '{0}'" , scheduleName) }; MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new ScheduleDetailQueryViewModel() { ScheduleName = scheduleName })); }