public ActionResult Edit(Store store) { StorePageViewModel pageViewModel = new StorePageViewModel(this); store.Territorys = Territorys(); store.AddressIding = AddressIding(); store.GetState = GetState(); try { if (ModelState.IsValid) { pageViewModel.UpdateStore(store); unit.Save(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Unable to save to db"); return(View(store)); } } catch (DbEntityValidationException e) { var r = e.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorText = string.Join(";", r); var exeptionText = string.Concat(e.Message, "Your Errors are: ", fullErrorText); ModelState.AddModelError("", exeptionText); } return(View(store)); }
public ActionResult Create(Store store) { StorePageViewModel pageViewModel = new StorePageViewModel(this); store.Territorys = Territorys(); store.AddressIding = AddressIding(); try { if (ModelState.IsValid) { pageViewModel.InsertStore(store); unit.Save(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Unable to save to db"); return(View(store)); } } catch (System.Exception ex) { throw ex; } return(View(store)); }
public ViewResult Details(int BusinessEntityID) { Store store = new Store(); StorePageViewModel pageViewModel = new StorePageViewModel(this); store = pageViewModel.SingleStore(BusinessEntityID); return(View(store)); }
// GET: Store public ActionResult Index(string searchString) { StorePageViewModel pageViewModel = new StorePageViewModel(this); var stores = pageViewModel.Build(); var storeList = stores; if (!String.IsNullOrEmpty(searchString)) { stores = storeList.Where(x => x.Name.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0); } return(View(stores)); }
public ActionResult Store(int id) { if (id == 0) { Response.Redirect("Home/Index"); } var model = new StorePageViewModel(); model.StoreName = (StoreName)id; //model.TodaysSalesTotal = _totalSales.GetTodaysSalesTotal(id.ToString()); model.CumulativeSalesForToday = _service.GetCumulativeSalesForToday(id.ToString()); //return Json(returnData, JsonRequestBehavior.AllowGet); return(View(model)); }
protected virtual StorePaginationViewModel BuildPagination(int totalCount, GetStoresParam param) { StorePageViewModel prevPage = null, nextPage = null; if (param.PageSize * param.PageNumber < totalCount) { nextPage = new StorePageViewModel { DisplayName = LocalizationProvider.GetLocalizedString(new GetLocalizedParam { Category = "Store", Key = "B_PaginationNext", CultureInfo = param.CultureInfo }), Url = StoreUrlProvider.GetStoresDirectoryUrl(new GetStoresDirectoryUrlParam { BaseUrl = param.BaseUrl, CultureInfo = param.CultureInfo, Page = param.PageNumber + 1 }) }; } if (param.PageNumber > 1) { prevPage = new StorePageViewModel { DisplayName = LocalizationProvider.GetLocalizedString(new GetLocalizedParam { Category = "Store", Key = "B_PaginationPrev", CultureInfo = param.CultureInfo }), Url = StoreUrlProvider.GetStoresDirectoryUrl(new GetStoresDirectoryUrlParam { BaseUrl = param.BaseUrl, CultureInfo = param.CultureInfo, Page = param.PageNumber - 1 }) }; } var pager = new StorePaginationViewModel { PreviousPage = prevPage, NextPage = nextPage }; return(pager); }
public ActionResult Edit(int BusinessEntityID) { Store store = new Store(); StorePageViewModel pageViewModel = new StorePageViewModel(this); store = pageViewModel.SingleStore(BusinessEntityID); store.Territorys = Territorys(); store.AddressIding = AddressIding(); store.GetState = GetState(); if (store == null) { return(HttpNotFound()); } return(View(store)); }
public IActionResult Index(StorePage currentPage) { var currentStore = _storeService.GetCurrentStoreViewModel(); var storesViewModel = new StoreViewModel { ShowDelivery = false, SelectedStore = currentStore != null ? currentStore.Code : "", SelectedStoreName = currentStore != null ? currentStore.Name : "", Stores = _storeService.GetAllStoreViewModels(), }; var store = new StorePageViewModel(currentPage) { StoreViewModel = storesViewModel }; return(View(store)); }
public StorePage() { InitializeComponent(); BindingContext = _storePageViewModel = new StorePageViewModel(Navigation); }