Exemplo n.º 1
0
        public ActionResult Shop()
        {
            List <SelectListItem> listItems   = new List <SelectListItem>();
            SelectListItem        placeholder = new SelectListItem();

            placeholder.Text     = "Selecteer een ploeg";
            placeholder.Value    = "-1";
            placeholder.Selected = true;
            listItems.Add(placeholder);
            ShopViewModel vm      = new ShopViewModel();
            List <Ploeg>  ploegen = plservice.All();

            for (int i = 0; i < ploegen.Count; i++)
            {
                SelectListItem li = new SelectListItem();
                li.Selected = false;
                li.Text     = ploegen.ElementAt(i).naam;
                li.Value    = i.ToString();
                listItems.Add(li);
            }
            vm.Abonnementen       = aservice.All();
            vm.abonnementPlaatsen = pservice.All();
            vm.ploegen            = listItems;
            vm.plaatsen           = pservice.All();
            vm.stadia             = staservice.All();
            return(View(vm));
        }
Exemplo n.º 2
0
        public ActionResult CreateShop(ShopViewModel model)
        {
            string userId = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                var shop = Mapper.Map <Shop>(model);
                using (var db = new UwtContext())
                {
                    shop.Owner       = db.Users.FirstOrDefault(u => u.Id == userId);
                    shop.DateCreated = DateTime.UtcNow;
                    shop.PageStyle   = db.PageStyles.Filter(userId).FirstOrDefault(p => p.Id == model.PageStyle);
                    shop.PageLayout  = db.PageLayouts.FirstOrDefault(p => p.Id == model.PageLayout);
                    db.Shops.Add(shop);
                    db.SaveChanges();
                }
                return(RedirectToAction("MyShops"));
            }
            using (var db = new UwtContext()) {
                var pageStyles  = db.PageStyles.Filter(userId).ToList();
                var pageLayouts = db.PageLayouts.ToList();
                ViewBag.PageStyles = pageStyles.Select(i => new SelectListItem {
                    Text = i.Name, Value = i.Id.ToString()
                });
                ViewBag.PageLayouts = pageLayouts.Select(i => new SelectListItem {
                    Text = i.Name, Value = i.Id.ToString()
                });
            }
            return(View(model));
        }
        void Awake()
        {
            var viewPrefab = Instantiate(_viewPrefab);
            var input      = viewPrefab.ShopController;
            var view       = viewPrefab.ShopView;

            var database   = new Database();
            var dataAccess = new ShopDataAccess(database);

            var viewModel = new ShopViewModel();

            // var itemCreator = new StandardLazyItemCreator( new List<ItemBluePrint>{new ItemBluePrint{Id = 1, UsageAction =() => { } }} );

            var itemCreator = new InternetDependantItemCreator();
            var inventory   = new InventoryEntity(itemCreator);

            var prices    = dataAccess.ItemPrices();
            var resources = new ResourceEntity();
            var shop      = new ShopEntity(inventory, resources, new ItemPriceData {
                Prices = prices
            });


            var useCaseInteractor = new BuyItemUseCase(dataAccess, viewModel, shop, inventory);

            view.Initialize(viewModel);
            input.Initialize(useCaseInteractor);
        }
Exemplo n.º 4
0
        public ShopViewModel GetAll()
        {
            var model = new ShopViewModel();

            model.Products = _productRepository.GetAll();
            return(model);
        }
Exemplo n.º 5
0
        // GET: Shop
        public async Task <ActionResult> Index()
        {
            if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
            {
                LocalStorageExtensions.Clear();
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
            }

            try
            {
                PaginationViewModel paginationViewModel = new PaginationViewModel()
                {
                    userId   = LocalStorageExtensions.Get(StorageType.UserId),
                    pageId   = 1,
                    pageSize = -1,
                };
                string response = await APICallerExtensions.APICallAsync("Shop/GetAll", paginationViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }
                ShopViewModel shopViewModel = new ShopViewModel();
                var           content       = JsonConvert.DeserializeObject <SingleResponse <List <Shop> > >(response);
                if (!content.DidError)
                {
                    shopViewModel.listShops = content.Model;

                    PaginationViewModel paginationViewModel2 = new PaginationViewModel()
                    {
                        pageId   = 1,
                        pageSize = -1,
                    };
                    string response2 = await APICallerExtensions.APICallAsync("Company/GetAll", paginationViewModel2, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                    if (response.ToLower().Contains("exception:"))
                    {
                        ModelState.AddModelError(string.Empty, response2);
                    }
                    var content2 = JsonConvert.DeserializeObject <SingleResponse <List <Company> > >(response2);
                    if (!content.DidError)
                    {
                        shopViewModel.listCompanies = content2.Model;
                    }

                    return(View(shopViewModel));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View());
            }
        }
        public async Task AddAsync_Calls_ProductCategoriesService()
        {
            //Arrange
            var productCategory = new ProductCategoryViewModel();

            int userId = 1;

            _mockClaimsGetter
            .Setup(x => x.UserId(It.IsAny <IEnumerable <Claim> >()))
            .Returns(userId);

            var shop = new ShopViewModel
            {
                Id = userId
            };

            _mockUserService
            .Setup(x => x.GetShopByUserIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(shop));

            //Act
            var result = await _productCategoriesController.AddAsync(productCategory);

            //Assert
            _mockProductCategoriesService.Verify(x => x.SaveAsync(productCategory), Times.Once());
        }
Exemplo n.º 7
0
        public ActionResult Index(string searchTerm, int?minimumPrice, int?maximumPrice, int?categoryID, int?sortBy, int?pageNo)
        {
            var           pageSize = ConfigurationsService.Instance.ShopPageSize();
            ShopViewModel model    = new ShopViewModel();

            model.SearchTerm = searchTerm;

            model.FeaturedCategories = CategoriesService.Instance.GetFeaturedCategories();
            model.MaximumPrice       = ProductsService.Instance.GetMaximumPrice();


            pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1;


            model.SortBy     = sortBy;
            model.CategoryID = categoryID;

            int totalCount = ProductsService.Instance.SearchProductsCount(searchTerm, minimumPrice, maximumPrice, categoryID, sortBy);

            model.Products = ProductsService.Instance.SearchProducts(searchTerm, minimumPrice, maximumPrice, categoryID, sortBy, pageNo.Value, pageSize);



            model.Pager = new Pager(totalCount, pageNo, pageSize);

            return(View(model));
        }
Exemplo n.º 8
0
        public async Task <ActionResult> ShopManage(ShopViewModel shop)
        {
            // Load Selection Lists.
            await LoadShopSelectLists(shop.AccountGuid);

            if (!ModelState.IsValid)
            {
                // Set Allow Entry.
                shop.AllowEntry = User.IsInRole(ApplicationRoles.ShopCreate.ToString()) || User.IsInRole(ApplicationRoles.ShopEdit.ToString());

                return(PartialView("_ShopManage", shop));
            }

            var shopDto = Mapper.Map <IShopDto>(shop);
            var update  = Mapper.Map <ShopViewModel>(Factory.Save(shopDto));

            Session["SelfScanListItems"]     = null;
            Session["ScanAnalysisListItems"] = null;

            update.AllowEntry = User.IsInRole(ApplicationRoles.ShopEdit.ToString());

            ModelState.Clear();
            SelectListItemCache.ClearCache(SelectListItemCacheType.RequestType);

            return(PartialView("_ShopManage", update));
        }
Exemplo n.º 9
0
        public async Task GetShopByIdAsync_Returns_ShopById()
        {
            //Arrange
            UserGetViewModel user = new UserGetViewModel
            {
                Email       = "*****@*****.**",
                DisplayName = "name1",
                UserRole    = "Customer"
            };

            ShopViewModel shop = new ShopViewModel
            {
                Address         = "address",
                PhoneNumber     = "0123654789",
                UserDisplayName = user.DisplayName,
                UserId          = user.Id,
                CUI             = "5555",
                IBAN            = "SE0000000000000000000000",
                SocialCapital   = 12
            };

            _mockUserService
            .Setup(x => x.GetShopByIdAsync(1))
            .Returns(Task.FromResult(shop));

            //Act
            var result = await _usersController.GetShopByIdAsync(1);

            //Assert
            result.Should().NotBeNull();
            result.Should().Equals(shop);
        }
Exemplo n.º 10
0
 public static ShopDto Map(this ShopViewModel shopViewModel)
 {
     Mapper.Initialize(m => m.CreateMap <ShopViewModel, ShopDto>()
                       .ForMember(s => s.Name, opts => opts.MapFrom(src => src.ShopName))
                       .ForMember(s => s.Address, opts => opts.MapFrom(src => src.Address.Map())));
     return(Mapper.Map <ShopDto>(shopViewModel));
 }
Exemplo n.º 11
0
        public async Task <ActionResult> ShopManage(Guid?id)
        {
            // Set Default.
            var shop = new ShopViewModel {
                AllowEntry = User.IsInRole(ApplicationRoles.ShopCreate.ToString())
            };

            // Load Shop.
            if (id.HasValue)
            {
                var shopDto = Factory.GetById <IShopDto>(id.Value.ToString());
                shop            = Mapper.Map <ShopViewModel>(shopDto);
                shop.AllowEntry = User.IsInRole(ApplicationRoles.ShopEdit.ToString());
            }
            else
            {
                // Default Pricing Plan.
                shop.PricingPlanId = 1;
            }

            // Load Selection Lists.
            await LoadShopSelectLists(shop.AccountGuid);

            // Return Partial.
            return(PartialView("_ShopManage", shop));
        }
Exemplo n.º 12
0
 public static IEnumerable <CategoryViewModel> GetCategories(this ShopViewModel model)
 {
     using (var db = new UwtContext()) {
         var categories = db.Categories.IncludeAll().Filter(model.Id).ToList();
         return(categories.Select(Mapper.Map <CategoryViewModel>).ToList());
     }
 }
Exemplo n.º 13
0
 public static IEnumerable <ProductViewModel> GetProducts(this ShopViewModel model)
 {
     using (var db = new UwtContext()) {
         var products = db.Products.IncludeAll().Filter(model.Id).ToList();
         return(products.Select(Mapper.Map <ProductViewModel>).ToList());
     }
 }
Exemplo n.º 14
0
 public static PageLayoutViewModel GetPageLayout(this ShopViewModel model)
 {
     using (var db = new UwtContext()) {
         var pageLayout = db.PageLayouts.IncludeAll().FirstOrDefault(o => o.Id == model.PageLayout);
         return(Mapper.Map <PageLayoutViewModel>(pageLayout));
     }
 }
Exemplo n.º 15
0
        public ActionResult EditShopPost(ShopViewModel viewModel, string returnUrl)
        {
            var model = new ShopModel(viewModel);

            this.Shop.SaveOrUpdate(model);
            return(this.RedirectLocal(string.Format("/merchat/myshops?merchantid={0}", model.Merchant.Id)));
        }
        public async Task AddAsync_Calls_ShopCategoryService()
        {
            //Arrange
            int userId     = 1;
            int categoryId = 1;

            _mockClaimsGetter
            .Setup(x => x.UserId(It.IsAny <IEnumerable <Claim> >()))
            .Returns(userId);

            var shop = new ShopViewModel
            {
                Id = userId
            };

            _mockUserService
            .Setup(x => x.GetShopByUserIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(shop));

            //Act
            await _shopCategoryController.AddAsync(categoryId);

            //Assert
            _mockShopCategoryService.Verify(x => x.SaveAsync(It.IsAny <ShopCategoryViewModel>()), Times.Once);
        }
        public async Task AddAsync_Returns_NoContentResult()
        {
            //Arrange
            int userId = 1;

            _mockClaimsGetter
            .Setup(x => x.UserId(It.IsAny <IEnumerable <Claim> >()))
            .Returns(userId);

            var shop = new ShopViewModel
            {
                Id = userId
            };

            _mockUserService
            .Setup(x => x.GetShopByUserIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(shop));


            //Act
            var result = await _productCategoriesController.AddAsync(new ProductCategoryViewModel());

            //Assert
            result.Should().BeOfType <NoContentResult>();
        }
Exemplo n.º 18
0
        public IHttpActionResult SaveShopModel(ShopViewModel model)
        {
            var savingModel = Mapper.Map <ShopViewModel, ShopEntity>(model);

            this.mShopService.Update(savingModel);
            return(this.Ok("Saved"));
        }
Exemplo n.º 19
0
        public IActionResult Shop()
        {
            ShopViewModel productsShopViewModel = new ShopViewModel();

            productsShopViewModel.Product = _productRepository.AllProducts;
            return(View(productsShopViewModel));
        }
Exemplo n.º 20
0
        public IHttpActionResult AddShopModel(ShopViewModel model)
        {
            var savingModel = Mapper.Map <ShopViewModel, ShopEntity>(model);

            this.mShopService.Add(savingModel);
            return(this.Ok("Added"));
        }
Exemplo n.º 21
0
        public ShopViewModel GetPage(int page, int pagesize, string category, string Type)
        {
            var model = new ShopViewModel();

            model.Products = _productRepository.GetPage(page, pagesize, category, Type);
            return(model);
        }
        public IActionResult Index(int ninjaId, int?selectedArmour)
        {
            var shopViewModel = new ShopViewModel
            {
                SelectedNinja = _ninjaRepository.GetDetailed(ninjaId),
                BuyAbleArmour = _armourRepository.Get()
            };

            if (selectedArmour != null)
            {
                shopViewModel.SelectedArmour = selectedArmour switch
                {
                    0 => ArmourEnum.Head,
                    1 => ArmourEnum.Necklace,
                    2 => ArmourEnum.Hands,
                    3 => ArmourEnum.Chest,
                    4 => ArmourEnum.Feet,
                    5 => ArmourEnum.Ring,
                    _ => shopViewModel.SelectedArmour
                };
            }

            var equippedArmour = shopViewModel.SelectedNinja.EquippedArmour.Select(na => na.Armour);

            shopViewModel.BuyAbleArmour = shopViewModel.BuyAbleArmour.Where(a => !equippedArmour.Contains(a));

            if (selectedArmour != null)
            {
                shopViewModel.BuyAbleArmour = shopViewModel.BuyAbleArmour.Where(a => a.ArmourType == shopViewModel.SelectedArmour);
            }

            return(View(shopViewModel));
        }
Exemplo n.º 23
0
        public List <ShopViewModel> GetShopsWithLevelAndBlock()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand("sPGetShopsWithLevelAndBlock", connection);

            command.CommandType = CommandType.StoredProcedure;

            connection.Open();
            SqlDataReader        reader   = command.ExecuteReader();
            List <ShopViewModel> shopList = new List <ShopViewModel>();

            while (reader.Read())
            {
                int    shopId    = Convert.ToInt32(reader["ShopId"]);
                string shopName  = reader["ShopName"].ToString();
                string contactNo = reader["ContactNo"].ToString();
                int    levelId   = Convert.ToInt32(reader["LevelId"]);
                int    blockId   = Convert.ToInt32(reader["BlockId"]);
                string blockNo   = reader["BlockNo"].ToString();

                ShopViewModel shopView = new ShopViewModel(shopId, shopName, contactNo, levelId, blockId, blockNo);
                shopList.Add(shopView);
            }

            reader.Close();
            connection.Close();

            return(shopList);
        }
Exemplo n.º 24
0
        public IActionResult Index(int?categoryId)
        {
            ViewData["categoryId"] = categoryId ?? 0;
            var model = new ShopViewModel();

            return(View(model));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Create(ShopViewModel shopViewModel)
        {
            try
            {
                shopViewModel.UserId = LocalStorageExtensions.Get(StorageType.UserId);
                shopViewModel.Photo  = shopViewModel.base64Picture;
                string response = await APICallerExtensions.APICallAsync("Shop/Create", shopViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(RedirectToAction(nameof(ShopController.Index), "Shop"));
                }
                var content = JsonConvert.DeserializeObject <SingleResponse <Shop> >(response);
                if (!content.DidError)
                {
                    return(RedirectToAction(nameof(ShopController.Index), "Shop"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(RedirectToAction(nameof(ShopController.Index), "Shop"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(RedirectToAction(nameof(ShopController.Index), "Shop"));
            }
        }
Exemplo n.º 26
0
        // GET: Shop
        public ActionResult Index(int page = 1, int count = 6, string category = null)
        {
            var managerProducts   = new ProductService();
            var managerCategories = new CategoryService();

            var products   = managerProducts.Get();
            var categories = managerCategories.Get();

            if (category != null)
            {
                products = products.Where(p => p.Category.Name == category).ToList();
            }

            int productsCount = products.Count;

            products = products.Skip((page - 1) * count)
                       .Take(count)
                       .ToList();

            this.ViewBag.TotalPages      = (productsCount + count - 1) / count;
            this.ViewBag.CurrentPage     = page;
            this.ViewBag.CurrentCategory = category;

            var model = new ShopViewModel
            {
                Categories = categories,
                Products   = products
            };

            return(this.View(model));
        }
Exemplo n.º 27
0
        public ActionResult EditShop(ShopViewModel model)
        {
            var userId = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                using (var db = new UwtContext())
                {
                    var shop = db.Shops.IncludeAll().Filter(userId).FirstOrDefault(s => s.Id == model.Id);
                    if (shop == null)
                    {
                        return(HttpNotFound());
                    }

                    var style  = db.PageStyles.Filter(userId).FirstOrDefault(s => s.Id == model.PageStyle);
                    var layout = db.PageLayouts.FirstOrDefault(l => l.Id == model.PageLayout);
                    shop.Update(model, style, layout);
                    db.SaveChanges();
                }
                return(RedirectToAction("EditShop", "Merchant", new { model.Id }));
            }
            using (var db = new UwtContext())
            {
                var pageStyles  = db.PageStyles.Filter(userId).ToList();
                var pageLayouts = db.PageLayouts.ToList();
                ViewBag.PageStyles = pageStyles.Select(i => new SelectListItem {
                    Text = i.Name, Value = i.Id.ToString(), Selected = i.Id == model.PageStyle
                });
                ViewBag.PageLayouts = pageLayouts.Select(i => new SelectListItem {
                    Text = i.Name, Value = i.Id.ToString(), Selected = i.Id == model.PageLayout
                });
                ViewBag.Invoices = db.Invoices.Filter(model.Id).Filter(DateTime.UtcNow.GetMonth(), DateTime.UtcNow).ToList().Select(Mapper.Map <InvoiceViewModel>).ToList();
            }
            return(View(model));
        }
Exemplo n.º 28
0
        public ActionResult Indx(int?id, int?subCatId, int?minPrice, int?maxPrice, int?sortField, int?crntPage, int?pageSize, string txt_search)
        {
            if (!string.IsNullOrEmpty(txt_search))
            {
                txt_search = txt_search.ToLower().Replace("#", "");
            }

            minPrice   = (minPrice ?? 1);
            maxPrice   = (maxPrice ?? 999999);
            sortField  = (sortField ?? 1);
            crntPage   = (crntPage ?? 1);
            pageSize   = (pageSize ?? 9);
            txt_search = (txt_search ?? "");

            ViewBag.catId      = id;
            ViewBag.subCatId   = subCatId;
            ViewBag.minPrice   = minPrice;
            ViewBag.maxPrice   = maxPrice;
            ViewBag.sortField  = sortField;
            ViewBag.crntPage   = crntPage;
            ViewBag.pageSize   = pageSize;
            ViewBag.txt_search = txt_search;


            var model = new ShopViewModel(id, subCatId, minPrice, maxPrice, sortField, crntPage, pageSize, txt_search);

            return(View("Index", model));
        }
Exemplo n.º 29
0
        public async Task AddShopAsync(ClaimsPrincipal user, ShopViewModel shopViewModel)
        {
            Shop shop = new Shop();

            var addressData = new AddressData
            {
                Address = shopViewModel.Address,
                City    = shopViewModel.City.ToUpper(),
                Country = "Italy"
            };

            var gls       = new GoogleLocationService();
            var latlong   = gls.GetLatLongFromAddress(addressData);
            var latitude  = latlong.Latitude;
            var longitude = latlong.Longitude;

            shop.Name         = shopViewModel.Name;
            shop.ShortDesc    = shopViewModel.ShortDesc;
            shop.City         = shopViewModel.City;
            shop.Address      = shopViewModel.Address;
            shop.Website      = shopViewModel.Website;
            shop.Phone        = shopViewModel.Phone;
            shop.Latitude     = latitude;
            shop.Longitude    = longitude;
            shop.InsertDate   = DateTime.Now;
            shop.InsertUserId = user.GetUserId();
            shop.UserId       = user.GetUserId();

            _dbContext.Shop.Add(shop);

            await _dbContext.SaveChangesAsync();
        }
Exemplo n.º 30
0
        public IActionResult Put(int id, [FromBody] ShopViewModel value)
        {
            // return a generic HTTP Status 500 (Not Found) if the client payload is invalid.
            if (value == null)
            {
                return(new StatusCodeResult(500));
            }

            var shop = _dbContext.Shops.Where(i => i.Id == id).FirstOrDefault();

            // return a HTTP Status 404 (Not Found) if we couldn't find a suitable shop.
            if (value == null)
            {
                return(NotFound(new { Error = String.Format("shop ID {0} has not been found", id) }));
            }

            // handle the update (on per-property basis)
            //shop.UserId = value.UserId;
            //shop.Description = value.Description;
            //shop.Flags = value.Flags;
            //shop.Notes = value.Notes;
            //shop.Text = value.Text;
            shop.Title = value.Title;
            //shop.Type = value.Type;

            // override any property that could be wise to set from server - side only
            shop.LastModifiedDate = DateTime.Now;

            // persist the changes into the Database.
            _dbContext.SaveChanges();

            // return the updated shop to the client.
            return(new JsonResult(Mapper.Map <ShopViewModel>(shop), DefaultJsonSettings));
        }