public void AddStoreDetailsTest() { int callCount = 0; int addStore = 0; int saveChanges = 0; var storeMock = new Mock <DbSet <StoreDetail> >(); context.Setup(m => m.StoreDetails).Returns(storeMock.Object); context.Setup(m => m.StoreDetails.Add(It.IsAny <StoreDetail>())).Callback(() => addStore = callCount++); context.Setup(m => m.SaveChanges()).Callback(() => saveChanges = callCount++); var TestAddStore = new StoreDetailsImplementation(); //storeMock.Verify(m => m.Add(It.IsAny<StoreDetail>()), Times.Once()); StoreDetail storeDetails = new StoreDetail() { StoreID = 1, StoreLocation = "United Kingdom", StoreName = "Sainsbury's" }; TestAddStore.AddStoreDetails(storeDetails); context.Verify(m => m.StoreDetails.Add(It.IsAny <StoreDetail>()), Times.Once); context.Verify(m => m.SaveChanges(), Times.Once); Assert.AreEqual(0, addStore); Assert.AreEqual(1, saveChanges); }
public bool UpdateSecurityKey(string GroupId, string counterId) { bool result = false; try { StoreDetail objstore = new StoreDetail(); string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { objstore = contextNew.StoreDetails.Where(x => x.CounterId == counterId).FirstOrDefault(); objstore.Status = "01"; contextNew.StoreDetails.AddOrUpdate(objstore); contextNew.SaveChanges(); result = true; } } catch (Exception ex) { newexception.AddException(ex, ""); } return(result); }
public ActionResult CreateStore([Bind(Include = "Id,LoginId,Name,Address,Remarks,StoreStatusId,StoreCategoryId,MasterCityId,MasterAreaId")] StoreDetail storeDetail, int?userApplicationId) { if (ModelState.IsValid) { if (CheckRegistrationFields(storeDetail, userApplicationId)) { if (store.AdminMgr.AddStoreDetails(storeDetail)) { //update Application status //get user application var userAppDetails = store.AdminMgr.GetUserApplication((int)userApplicationId); userAppDetails.UserApplicationStatusId = 2; //Accepted if (store.AdminMgr.EditUserApplication(userAppDetails)) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Unable to Update Application status to accepted"); } } else { ModelState.AddModelError("", "Unable to Add new Store Detail. "); } } } ViewBag.MasterAreaId = new SelectList(store.RefDbLayer.GetMasterAreas(), "Id", "Name", storeDetail.MasterAreaId); ViewBag.MasterCityId = new SelectList(store.RefDbLayer.GetMasterCities(), "Id", "Name", storeDetail.MasterCityId); ViewBag.StoreCategoryId = new SelectList(store.RefDbLayer.GetStoreCategories(), "Id", "Name", storeDetail.StoreCategoryId); ViewBag.StoreStatusId = new SelectList(store.RefDbLayer.GetStoreStatus(), "Id", "Name", storeDetail.StoreStatusId); ViewBag.UserApplicationId = userApplicationId; return(View(storeDetail)); }
public ActionResult Products(int?id) { if (id != null) { int storeId = (int)id; var storeItems = storeMgr.getStoreItems(storeId); var storeDetails = storeMgr.getStoreDetails(storeId); var defaultImg = "/img/placeholders/placeholder-product.png"; ViewBag.StoreName = storeDetails.Name; ViewBag.StoreAddress = storeDetails.Address; ViewBag.StoreImg = storeDetails.StoreImages.FirstOrDefault() != null?storeDetails.StoreImages.FirstOrDefault().ImageUrl : defaultImg; //Get next suggested Store StoreDetail store = new StoreDetail(); do { store = storeMgr.getRandomStore(); } while (store.Id == id); ViewBag.nextStoreId = store.Id; ViewBag.nextStore = store.Name; ViewBag.nextStoreImg = store.StoreImages.FirstOrDefault().ImageUrl; return(View(storeItems)); } else { return(RedirectToAction("Index", "Error")); } }
// GET: Store/StoreDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StoreDetail storeDetail = storeFactory.StoreMgr.getStoreDetails((int)id); if (storeDetail == null) { return(HttpNotFound()); } ViewBag.StoreId = id; ViewBag.MasterAreaId = new SelectList(db.MasterAreas, "Id", "Name", storeDetail.MasterAreaId); ViewBag.MasterCityId = new SelectList(db.MasterCities, "Id", "Name", storeDetail.MasterCityId); ViewBag.StoreCategoryId = new SelectList(db.StoreCategories, "Id", "Name", storeDetail.StoreCategoryId); ViewBag.StoreStatusId = new SelectList(db.StoreStatus, "Id", "Name", storeDetail.StoreStatusId); var storeImg = storeFactory.StoreMgr.GetStoreImg(storeDetail.Id); ViewBag.StoreImg = storeImg; return(View(storeDetail)); }
public ActionResult Edit([Bind(Include = "Id,LoginId,Name,Address,Remarks,StoreStatusId,StoreCategoryId,MasterCityId,MasterAreaId")] StoreDetail storeDetail) { if (ModelState.IsValid) { if (store.AdminMgr.EditStoreDetails(storeDetail)) { return(RedirectToAction("Index")); } } var identityUSers = store.RefDbLayer.GetAspNetUsers(); List <SelectListItem> userList = new List <SelectListItem>(); foreach (IdentityUSer user in identityUSers) { userList.Add(new SelectListItem() { Text = user.UserName, Value = user.LoginId }); } ViewBag.LoginId = new SelectList(userList, "Value", "Text", storeDetail.LoginId); ViewBag.MasterAreaId = new SelectList(store.RefDbLayer.GetMasterAreas(), "Id", "Name", storeDetail.MasterAreaId); ViewBag.MasterCityId = new SelectList(store.RefDbLayer.GetMasterCities(), "Id", "Name", storeDetail.MasterCityId); ViewBag.StoreCategoryId = new SelectList(store.RefDbLayer.GetStoreCategories(), "Id", "Name", storeDetail.StoreCategoryId); ViewBag.StoreStatusId = new SelectList(store.RefDbLayer.GetStoreStatus(), "Id", "Name", storeDetail.StoreStatusId); return(View(storeDetail)); }
public List <StoreDetail> GetAllStoresWithAlbum(int albumId, bool getStores) { if (getStores) { // You're in the right place } using (var ctx = new ApplicationDbContext()) { var album = ctx .Albums .Single(e => e.AlbumId == albumId); List <StoreDetail> storeList = new List <StoreDetail>(); var stores = album.Stores.ToArray(); foreach (var store in stores) { StoreDetail listItem = new StoreDetail(); listItem.StoreId = store.StoreId; listItem.StoreName = store.StoreName; listItem.Address = store.Address; listItem.StoreRating = store.StoreRating; storeList.Add(listItem); } return(storeList); } }
public bool AddListProToStore(IEnumerable <ProductStoreModel> ds, int storeID) { try { StoreDetail sd = new StoreDetail(); using (var db = new DbEntities()) { foreach (var pro in ds) { sd = new StoreDetail() { ProductID = pro.ProductID, Quantity = pro.Quantity, StoreID = storeID }; db.StoreDetails.Add(sd); db.SaveChanges(); } } return(true); } catch { return(false); } }
// GET: Admin/StoreDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StoreDetail storeDetail = store.AdminMgr.GetStoreDetail((int)id); if (storeDetail == null) { return(HttpNotFound()); } var identityUSers = store.RefDbLayer.GetAspNetUsers(); List <SelectListItem> userList = new List <SelectListItem>(); foreach (IdentityUSer user in identityUSers) { userList.Add(new SelectListItem() { Text = user.UserName, Value = user.LoginId }); } ViewBag.LoginId = new SelectList(userList, "Value", "Text", storeDetail.LoginId); ViewBag.MasterAreaId = new SelectList(store.RefDbLayer.GetMasterAreas(), "Id", "Name", storeDetail.MasterAreaId); ViewBag.MasterCityId = new SelectList(store.RefDbLayer.GetMasterCities(), "Id", "Name", storeDetail.MasterCityId); ViewBag.StoreCategoryId = new SelectList(store.RefDbLayer.GetStoreCategories(), "Id", "Name", storeDetail.StoreCategoryId); ViewBag.StoreStatusId = new SelectList(store.RefDbLayer.GetStoreStatus(), "Id", "Name", storeDetail.StoreStatusId); return(View(storeDetail)); }
public bool CheckRegistrationFields(StoreDetail storeDetail, int?appId) { bool isValid = true; if (storeDetail.Name.IsNullOrWhiteSpace()) { ModelState.AddModelError("Name", "Name field is empty."); isValid = false; } if (storeDetail.Address.IsNullOrWhiteSpace()) { ModelState.AddModelError("Address", "Address field is empty."); isValid = false; } if (storeDetail.LoginId.IsNullOrWhiteSpace()) { ModelState.AddModelError("LoginId", "Email field is empty."); isValid = false; } if (appId == null) { ModelState.AddModelError("", "Application Id field is empty."); isValid = false; } return(isValid); }
public void AddStoreDetails(StoreDetail storeDetails) { using (var context = new CookieStoreDBContext()) { context.StoreDetails.Add(storeDetails); context.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { StoreDetail storeDetail = storeFactory.StoreMgr.getStoreDetails((int)id); //db.StoreDetails.Remove(storeDetail); //db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { StoreDetail storeDetail = db.StoreDetails.Find(id); db.StoreDetails.Remove(storeDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public Payout(Client client) : base(client) { _storeDetailAndSubmitThirdParty = new StoreDetailAndSubmitThirdParty(this); _confirmThirdParty = new ConfirmThirdParty(this); _declineThirdParty = new DeclineThirdParty(this); _storeDetail = new StoreDetail(this); _submitThirdParty = new SubmitThirdParty(this); _payoutService = new PayoutService(this); }
public bool RemovestoreDetails(StoreDetail storeDetail) { try { return(adminDb.RemoveStoreDetails(storeDetail)); } catch { return(false); } }
public bool EditStoreDetails(StoreDetail storeDetail) { try { return(adminDb.EditStoreDetails(storeDetail)); } catch { return(false); } }
public ActionResult DeleteConfirmed(int id) { StoreDetail storeDetail = store.AdminMgr.GetStoreDetail((int)id); if (store.AdminMgr.RemovestoreDetails(storeDetail)) { return(RedirectToAction("Index")); } return(View(storeDetail)); }
public bool AddStoreDetails(StoreDetail storeDetail) { try { db.StoreDetails.Add(storeDetail); db.SaveChanges(); return(true); } catch { return(false); } }
public bool EditStoreDetails(StoreDetail storeDetail) { try { db.Entry(storeDetail).State = EntityState.Modified; db.SaveChanges(); return(true); } catch { return(false); } }
public bool RemoveStoreDetails(StoreDetail storeDetail) { try { db.StoreDetails.Remove(storeDetail); db.SaveChanges(); return(true); } catch { return(false); } }
public JsonResult GetStoreDetail(string URL) { try { StoreDetail store = new StoreDetail(); store = ProjectSession.StoreSession; return(Json(store, JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }
public IHttpActionResult Get(int id) { StoreDetail storeDetail = _storeDetails.GetStoreDetail(id); if (storeDetail != null) { return(Ok(storeDetail)); } else { return(NotFound()); } }
public async Task <IActionResult> UpSertStoreDetail(StoreDetail model) { if (model.Id > 0) { var updateModel = CommanCRUDHelper.CommanUpdateCode(model, 1); var updateResponse = await _IStoreDetailService.Update(updateModel); return(Json(ResponseHelper.GetResponseMessage(updateResponse))); } var createModel = CommanCRUDHelper.CommanCreateCode(model, 1); var createResponse = await _IStoreDetailService.CreateEntity(createModel); return(Json(ResponseHelper.GetResponseMessage(createResponse))); }
public ActionResult Edit([Bind(Include = "Id,LoginId,Name,Address,Remarks,StoreStatusId,StoreCategoryId,MasterCityId,MasterAreaId")] StoreDetail storeDetail) { if (ModelState.IsValid) { db.Entry(storeDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MasterAreaId = new SelectList(db.MasterAreas, "Id", "Name", storeDetail.MasterAreaId); ViewBag.MasterCityId = new SelectList(db.MasterCities, "Id", "Name", storeDetail.MasterCityId); ViewBag.StoreCategoryId = new SelectList(db.StoreCategories, "Id", "Name", storeDetail.StoreCategoryId); ViewBag.StoreStatusId = new SelectList(db.StoreStatus, "Id", "Name", storeDetail.StoreStatusId); return(View(storeDetail)); }
// GET: Store/StoreDetails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StoreDetail storeDetail = storeFactory.StoreMgr.getStoreDetails((int)id); if (storeDetail == null) { return(HttpNotFound()); } return(View(storeDetail)); }
// GET: Shopper/StoreDetails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StoreDetail storeDetail = db.StoreDetails.Find(id); if (storeDetail == null) { return(HttpNotFound()); } return(View(storeDetail)); }
// GET: Admin/StoreDetails/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StoreDetail storeDetail = store.AdminMgr.GetStoreDetail((int)id); if (storeDetail == null) { return(HttpNotFound()); } return(View(storeDetail)); }
public bool CreateStoreDetail(StoreDetail storeDetail) { try { db.StoreDetails.Add(storeDetail); db.SaveChanges(); return(true); } catch (Exception ex) { throw ex; //return false; } }
public bool AddNewPro(StoreDetail sd) { try { var db = new DbEntities(); db.StoreDetails.Add(sd); db.SaveChanges(); return(true); } catch { return(false); } }
public bool UpdateQty(StoreDetail sd) { try { var db = new DbEntities(); var sdo = db.StoreDetails.SingleOrDefault(t => t.Product.ProductID == sd.ProductID && t.Store.StoreID == sd.StoreID); sdo.Quantity = sd.Quantity; db.SaveChanges(); return(true); } catch { return(false); } }