public async Task AddAsyncTestFaildAsync(string databasename, string address, string name) { StoreStruct storeStruct = new StoreStruct { Address = address, Name = name }; using (InMemoryContext context = new InMemoryContext(databasename)) { StoreManager store = new StoreManager(context); await context.Stores.AddAsync(new StoresEntity { Name = name }); Assert.ThrowsAsync <ExistsInDBException>(async() => await store.AddAsync(storeStruct)); } }
public async Task GetAllAsyncOk1Async(string databasename, string address, string name) { StoreStruct storeStruct = new StoreStruct { Address = address, Name = name }; using (InMemoryContext context = new InMemoryContext(databasename)) { StoreManager store = new StoreManager(context); await context.Stores.AddAsync(new StoresEntity { Name = name, Address = address }); IEnumerable <StoreStruct> storeStructs = await store.GetAllAsync(); Assert.NotNull(storeStructs); } }
public async Task AddAsyncTestOkAsync(string databasename, string address, string name) { StoreStruct storeStruct = new StoreStruct { Address = address, Name = name }; using (InMemoryContext context = new InMemoryContext(databasename)) { StoreManager store = new StoreManager(context); (bool result, int id) = await store.AddAsync(storeStruct); Assert.IsTrue(result); } }
public async Task <IActionResult> AddProductToStore(AddProductToStoreModel addPtoSModel) { AddProductToStoreModel addProductToStore; if (ModelState.IsValid) { try { await manager.AddProductToStoreAsync(addPtoSModel.StoreName, addPtoSModel.ProductName); ViewData["Success"] = "Product added to store " + addPtoSModel.StoreName; } catch (ExistsInDBException e) { ViewData["Errors"] = e.Message; } catch (NoExistInDbException e) { ViewData["Errors"] = e.Message; } } else { ViewData["Errors"] = "Incorrect data entered or some fields are empty"; } // addProductToStore = new AddProductToStoreModel { ProductStructs = new List<ProductStruct>(), StoreName = storeName }; try { StoreStruct storeStruct = await storeManager.GetOneAsync(addPtoSModel.StoreName); ViewData.Add("StoreName", storeStruct.Name); addProductToStore = new AddProductToStoreModel { ProductStructs = storeStruct.Products, StoreName = storeStruct.Name }; } catch (NoExistInDbException) { addProductToStore = new AddProductToStoreModel { ProductStructs = new List <ProductStruct>(), StoreName = addPtoSModel.StoreName }; } return(View(addProductToStore)); }
public async Task <ActionResult> Edit(string id, Recommendation recommendation) { isAdminLayout(); try { StoreStruct iceCream = await ds.addRecommendation(id, recommendation); ViewBag.GoogleApi = Defenitions.GOOGLE_MAPS_VIEW + Defenitions.GOOGLE_MAPS_API + "&callback = myMap"; return(View("Details", iceCream)); } catch (Exception e) { ViewBag.Error = e.Message; return(View()); } //return View(); }
public void StoreStructTest() { using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); StoreStruct storeStruct = new StoreStruct(); Placement place = new Placement(15, 2, 1, 10, 10); storeStruct.Persist(place, session); UInt64 id = storeStruct.Id; session.Commit(); using (SessionNoServer session2 = new SessionNoServer(systemDir)) { session2.BeginRead(); StoreStruct storeStruct2 = (StoreStruct)session2.Open(id); if (storeStruct2.in16 != 16) { Console.WriteLine("Should be 16"); } session2.Commit(); } } }
public async Task <IActionResult> StoreProducts(string storeName) { AddProductToStoreModel addProductToStore; try { StoreStruct storeStruct = await storeManager.GetOneAsync(storeName); ViewData.Add("StoreName", storeStruct.Name); addProductToStore = new AddProductToStoreModel { ProductStructs = storeStruct.Products, StoreName = storeStruct.Name }; } catch (NoExistInDbException) { addProductToStore = new AddProductToStoreModel { ProductStructs = new List <ProductStruct>(), StoreName = storeName }; } return(PartialView(addProductToStore)); }