// GET: Store/Edit/5 public async Task <ActionResult> Edit(Guid id, FormCollection form, LoadCompanies LoadCompaniesService, LoadSpecificStore LoadSpecificStoreService) { ViewBag.error = ""; try { // Filling companies to select in droppdownlist ViewBag.CompaniesList = new SelectList(LoadCompaniesService.LoadMultiCompanies(), "Id", "Name"); } catch (Exception e) { ViewBag.CompaniesList = new SelectList("---emty list---"); ViewBag.error = viebagMessage(e); } StoreModel StoreDetails = new StoreModel(); try { StoreDetails = await LoadSpecificStoreService.SpecificStoreAsync(id); StoreDetails.id = id; } catch (Exception e) { Console.Write(e); ViewBag.error = viebagMessage(e); } return(View(StoreDetails)); }
// GET: Store/Create public ActionResult Create(LoadCompanies LoadCompaniesService) { try { // Filling companies to select in droppdownlist ViewBag.CompaniesList = new SelectList(LoadCompaniesService.LoadMultiCompanies(), "Id", "Name"); } catch (Exception e) { ViewBag.CompaniesList = new SelectList("---emty list---"); Console.Write("Unable to get list of companies. Couse: " + e); viebagMessage(e); } return(View()); }
// GET: Company public ActionResult Index(LoadCompanies LoadCompaniesService) { ViewBag.error = ""; List <CompanyModel> DisplayListCompanies = new List <CompanyModel>(); try { DisplayListCompanies = LoadCompaniesService.LoadMultiCompanies(); } catch (Exception e) { ViewBag.error = viebagMessage(e); } return(View(DisplayListCompanies)); }
public async Task <ActionResult> Create(StoreModel StoreUserCreationData, FormCollection form, LoadCompanies LoadCompaniesService, CreateStore CreateStoreService) { ViewBag.CompaniesList = new SelectList(LoadCompaniesService.LoadMultiCompanies(), "Id", "Name"); ViewBag.error = ""; StoreUserCreationData.CompanyId = new Guid(form["CompanyID"]); // Reciving values from list try { if (StoreUserCreationData.CompanyId == null || StoreUserCreationData.CompanyId == Guid.Empty) { Console.Write(StoreUserCreationData.CompanyId); ViewBag.error = "Please select a company the store shoude belong to."; return(View()); } } catch (Exception e) { ViewBag.error = viebagMessage(e); } try { await CreateStoreService.createStore(StoreUserCreationData); return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.error = viebagMessage(e); return(View()); } }