public async Task <IActionResult> AddService(ServicePriceViewModel model) { if (!ModelState.IsValid) { return(View(model)); } await this.materials.AddServiceAsync( model.Date, model.PlateExposing, model.MachineSetup, model.Impression, model.Packing); return(RedirectToAction(nameof(AllService))); }
public async Task <IActionResult> EditService(int id, ServicePriceViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var success = await this.materials.EditServiceAsync( id, model.Date, model.PlateExposing, model.MachineSetup, model.Impression, model.Packing); if (!success) { return(NotFound()); } return(RedirectToAction(nameof(AllService))); }
public async Task <IActionResult> Index(string sortParam, int searchField, string searchParam, int studentPage = 1, int PageSize = 3) { ServicePriceViewModel ServicePriceVM = new ServicePriceViewModel() { ServicePrices = new List <Models.ServicePrice>() }; if (searchField != 0) { ViewBag.DropDownColor = "abc"; } FillServiceIndex(searchField); ServicePriceVM.ServicePrices = await db.ServicePrices.ToListAsync(); if (searchField != 0) { ServicePriceVM.ServicePrices = db.ServicePrices.Where(a => a.ServiceID == searchField).ToList(); } StringBuilder param = new StringBuilder(); param.Append("/ServicePrice?studentPage=:"); param.Append("&searchField="); if (searchField != 0) { param.Append(searchField); } param.Append("&sortParam="); if (sortParam != null) { param.Append(sortParam); } if (PageSize <= 0) { PageSize = 3; } ViewBag.PageSize = PageSize; param.Append("&PageSize="); if (PageSize != 0) { param.Append(PageSize); } var count = ServicePriceVM.ServicePrices.Count; if (count == 0) { studentPage = 0; } if (sortParam == "SortDec") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderByDescending(p => p.Service.ServiceName) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortDec"; } else if (sortParam == "SortDecLocalPrice") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderByDescending(p => p.LocalPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortDecLocalPrice"; } else if (sortParam == "SortAscLocalPrice") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderBy(p => p.LocalPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortAscLocalPrice"; } else if (sortParam == "SortDecFormula") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderByDescending(p => p.ForeignerFormulaPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortDecFormula"; } else if (sortParam == "SortAscFormula") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderBy(p => p.ForeignerFormulaPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortAscFormula"; } else if (sortParam == "SortDecFixed") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderByDescending(p => p.ForeignerFixedPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortDecFixed"; } else if (sortParam == "SortAscFixed") { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderBy(p => p.ForeignerFixedPrice) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortAscFixed"; } else { ServicePriceVM.ServicePrices = ServicePriceVM.ServicePrices.OrderBy(p => p.Service.ServiceName) .Skip((studentPage - 1) * PageSize) .Take(PageSize).ToList(); ViewBag.sortParamView = "SortAsc"; } //doctorScheduleVM.DoctorSchedules = doctorScheduleVM.DoctorSchedules.OrderBy(p => p.DoctorName) //.Skip((studentPage - 1) * PageSize) //.Take(PageSize).ToList(); ////ViewBag.sortParamView = "SortAsc"; ServicePriceVM.PagingInfo = new PagingInfo() { CurrentPage = studentPage, ItemsPerPage = PageSize, TotalItems = count, urlParam = param.ToString(), //PagerSize = 5, }; //if(country!=0) //{ // return View("Index"); //} return(View(ServicePriceVM)); }