Exemplo n.º 1
0
 public static CatalogViewModel ToResellerViewModel(this CatalogModel resellerCatalog)
 {
     return(new CatalogViewModel
     {
         Id = resellerCatalog.Id,
         Name = resellerCatalog.Name,
         Description = resellerCatalog.Description,
         Default = resellerCatalog.Default,
         CreateDate = resellerCatalog.CreateDate,
         Products = resellerCatalog.Products?.Select(p => p.ToResellerCatalogProductViewModel()),
     });
 }
Exemplo n.º 2
0
        public IActionResult Catalog()
        {
            CatalogModel    obj         = new CatalogModel();
            LayoutViewModel layoutModel = InitLayoutModel();

            obj.LayoutModel        = layoutModel;
            obj.GetProducts        = _products.GetProducts.ToList();
            obj.ProductsCount      = _products.GetProducts.Count();
            obj.GetProductImages   = _productImages.GetProductImages.ToList();
            obj.ProductImagesCount = _productImages.GetProductImages.Count();
            return(View(obj));
        }
Exemplo n.º 3
0
        public IActionResult Index(int id)
        {
            CatalogModel model = new CatalogModel()
            {
                // sludinājumi kategorijā
                Ads = _ads.GetByCategory(id),
                // atvērtās kategorijas dati
                Categories = _categories.Get(id)
            };

            return(View(model));
        }
Exemplo n.º 4
0
 public void Remove(CatalogModel catalog)
 {
     using (BookDataContext context = BookDataContext.Connect())
     {
         CatalogModel model = context.Catalogs.FirstOrDefault(t => t.Id == catalog.Id);
         if (model != null)
         {
             context.Catalogs.DeleteOnSubmit(model);
             context.SubmitChanges();
         }
     }
 }
Exemplo n.º 5
0
        public async Task <bool> CreateCatalog(CatalogModel model, int UserId)
        {
            var objCatalog = Mapper.Map <soft_Catalog>(model);

            objCatalog.DateCreate     = DateTime.Now;
            objCatalog.EmployeeCreate = UserId;
            objCatalog.DateUpdate     = null;
            unitOfWork.CatalogRepository.Add(objCatalog);

            await unitOfWork.SaveChanges();

            return(true);
        }
Exemplo n.º 6
0
        public ActionResult Create(CatalogModel catalogmodel)
        {
            if (ModelState.IsValid)
            {
                db.Catalogs.Add(catalogmodel);
                catalogmodel.CreateTime = DateTime.Now;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(catalogmodel));
        }
Exemplo n.º 7
0
        public ActionResult GetAssets([DataSourceRequest] DataSourceRequest request, string catalogId)
        {
            CatalogModel.BindDataSourceRequest(Request, ref request);

            var response = CatalogModel.GetCatalogItems(request, catalogId);
            var ret      = new
            {
                Data = response.Items,
                response.Total
            };

            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        private void TreeViewItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 实现右键选中
            UIElement    element   = e.OriginalSource as UIElement;
            TreeViewItem container = GetNearestContainer(element);
            CatalogModel model     = container.DataContext as CatalogModel;

            if (model != null)
            {
                model.IsSelected = true;
            }
            _isCheckDrag = false;
        }
        public async Task <CatalogModel> CreateCatalog(CatalogModel model)
        {
            var response = await _client.PostAsJson($"/Catalog", model);

            if (response.IsSuccessStatusCode)
            {
                return(await response.ReadContentAs <CatalogModel>());
            }
            else
            {
                throw new Exception("Something went wrong when calling api.");
            }
        }
Exemplo n.º 10
0
        public async Task <CatalogModel> CreateCatalog(CatalogModel model)
        {
            var message = new HttpRequestBuilder(_settings.BaseAddress)
                          .SetPath(_settings.CatalogPath)
                          .HttpMethod(HttpMethod.Post)
                          .GetHttpMessage();

            var json = JsonConvert.SerializeObject(model);

            message.Content = new StringContent(json, Encoding.UTF8, "application/json");

            return(await SendRequest <CatalogModel>(message));
        }
Exemplo n.º 11
0
        private async void Grid_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            CatalogModel model = e.NewValue as CatalogModel;

            try
            {
                await bookmarkGrid.FillData(model);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 12
0
        public IActionResult Index()
        {
            var cart    = _checkoutService.GetCart();
            var catalog = _shoppingContext.Catalog.ToList();

            var model = new CatalogModel
            {
                CartId  = cart.Id,
                Catalog = catalog
            };

            return(View(model));
        }
Exemplo n.º 13
0
        public async Task CreateNewCatalog(int companyId, int sourceCatalogId, CatalogModel resellerCatalogModel)
        {
            var company = await _dbContext.Companies.Include(c => c.CompanyCatalogs.Select(cc => cc.Catalog.CatalogProductItems.Select(cpi => cpi.ProductItem))).FirstOrDefaultAsync(c => c.Id == companyId);

            if (company == null)
            {
                throw new CompanyNotFoundException($"CompanyId: {companyId}");
            }

            var sourceCompanyCatalog = company.CompanyCatalogs.FirstOrDefault(cc =>
                                                                              cc.CatalogType == CatalogType.MyCatalog && cc.CatalogId == sourceCatalogId);

            if (sourceCompanyCatalog == null)
            {
                throw new NonExistingCompanyCatalogException($"CompanyId {companyId}, CatalogId {sourceCatalogId}");
            }

            var newCatalog = new Entities.Catalog.Catalog
            {
                Name        = resellerCatalogModel.Name,
                Description = resellerCatalogModel.Description
            };

            sourceCompanyCatalog.Catalog.CatalogProductItems.ForEach(productItem =>
            {
                newCatalog.CatalogProductItems.Add(new CatalogProductItem
                {
                    Catalog          = newCatalog,
                    ProductItem      = productItem.ProductItem,
                    RetailPrice      = productItem.RetailPrice,
                    ResellerPrice    = productItem.ResellerPrice,
                    FixedRetailPrice = productItem.FixedRetailPrice,
                    Available        = productItem.Available
                });
            });

            _dbContext.Catalogs.Add(newCatalog);
            _dbContext.CompanyCatalogs.Add(new CompanyCatalog
            {
                Catalog     = newCatalog,
                Company     = company,
                CatalogType = CatalogType.MyCatalog
            });

            foreach (var assignedCompanies in resellerCatalogModel.CompaniesAssignedToCatalog)
            {
                await AssignCatalogToCompany(companyId, assignedCompanies.CompanyId, newCatalog.Id);
            }

            await _dbContext.SaveChangesAsync();
        }
 public SkyDriveCatalogReader(
     CatalogModel catalog,
     ILiveLogin liveLogin,
     IStorageStateSaver storageStateSaver,
     DownloadController downloadController,
     ICatalogRepository catalogRepository)
 {
     _catalog            = catalog;
     _liveLogin          = liveLogin;
     _storageStateSaver  = storageStateSaver;
     _downloadController = downloadController;
     _catalogRepository  = catalogRepository;
     CatalogId           = catalog.Id;
 }
Exemplo n.º 15
0
        public void Post_AddsCatagory()
        {
            // Arrange
            mockDataService.Setup(d => d.AddNewCatalog(It.IsAny <CatalogModel>())).Returns(true);
            var          catalogController = this.CreateCatalogController();
            CatalogModel catalog           = new CatalogModel(2, "cat4", "Public");

            // Act
            var result = catalogController.AddNewCatalog(catalog);

            // Assert
            Assert.AreEqual(result, catalog);
            this.mockRepository.VerifyAll();
        }
Exemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            var model = new CatalogModel(hdfTableDM.Text)
            {
                Name = txtTenDM.Text
            };

            //create
            CatalogController.Create(hdfTableDM.Text, model);

            //reload grid
            grpCategory.Reload();
            ResetInputCategory();
        }
Exemplo n.º 17
0
 public IActionResult Post([FromBody] CatalogModel catalog)
 {
     try
     {
         //catalog.UserId = CurrentUserId;
         var newCatalog = _catalogService.Add(catalog.ToDomainModel());
         return(CreatedAtAction("Get", new { newCatalog.Id }, newCatalog.ToApiModel()));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("AddCatalog", ex.Message);
         return(BadRequest(ModelState));
     }
 }
Exemplo n.º 18
0
        public void ReOrderChilds(CatalogModel parentModel)
        {
            if (parentModel == null)
            {
                throw new ArgumentNullException(nameof(parentModel));
            }
            List <CatalogModel> newOrderChilds = parentModel.Children.OrderByDescending(p => p.Order).ToList();

            parentModel.Children.Clear();
            foreach (var item in newOrderChilds)
            {
                parentModel.Children.Add(item);
            }
        }
Exemplo n.º 19
0
        public async Task FillData(CatalogModel model)
        {
            this.CurrentCatalogModel = model;
            if (model == null || string.IsNullOrWhiteSpace(model.Id))
            {
                this.FillData(new List <BookmarkView>());
            }
            else
            {
                List <BookmarkView> bookmarks = await BookmarkService.GetListByCatalog(model.Id);

                this.FillData(bookmarks);
            }
        }
Exemplo n.º 20
0
 public Catalog(CatalogModel catalog)
 {
     Code     = catalog.Code ?? "";
     DescRu   = catalog.DescRu ?? "";
     DescUk   = catalog.DescUk ?? "";
     Id       = catalog.Id;
     ParentId = catalog.ParentId ?? null;
     Ru       = catalog.ru;
     Uk       = catalog.uk;
     Type     = catalog.Type;
     IsUsable = catalog.IsUsable;
     Filter   = catalog.Filter;
     Updated  = catalog.Updated;
 }
        public ActionResult Index()
        {
            var catalogItems = new List <CatalogItem>();
            var products     = _productsRepository.GetProducts();
            var username     = Request.QueryString["user"];

            IEnumerable <Promotion> promotions          = null;
            IEnumerable <Product>   recommendedProducts = new List <Product>();

            CustomerRec customer = null;

            if (User.Identity.IsAuthenticated)
            {
                customer = _customerRepository.GetCustomerByName(User.Identity.Name);

                if (customer != null)
                {
                    promotions          = _promotionsRepository.GetPromotions(customer.CustomerId);
                    recommendedProducts = _productsRepository.GetRecommendedProducts(customer.CustomerId);
                }
            }
            else if (!String.IsNullOrEmpty(username))
            {
                customer            = _customerRepository.GetCustomerByName(username);
                promotions          = _promotionsRepository.GetPromotions(customer.CustomerId);
                recommendedProducts = _productsRepository.GetRecommendedProducts(customer.CustomerId);
            }

            var recommendedCatalogItems = recommendedProducts
                                          .OrderBy(p => p.Name)
                                          .Select(recommendedProduct => ProductToCatalogItem(promotions, customer, recommendedProduct))
                                          .ToList();

            foreach (var product in products.OrderBy(p => p.Name))
            {
                if (User.Identity.IsAuthenticated && customer != null)
                {
                    var playCount = _productsRepository.GetSongPlayCount(product.Id, customer.CustomerId);

                    product.PlayCount = playCount;
                }

                catalogItems.Add(ProductToCatalogItem(promotions, customer, product));
            }

            var catalogModel = new CatalogModel(catalogItems, recommendedCatalogItems);

            return(View(catalogModel));
        }
Exemplo n.º 22
0
        public virtual ActionResult Modify(CatalogModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Modify);
            var result = new Dictionary <string, object>();
            var rev    = this.SaveEntity(entity);
            var mess   = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Exemplo n.º 23
0
 /// <summary>
 /// 折叠所有
 /// </summary>
 public void CollapseAll()
 {
     for (int i = 0; i < this.AllCatalogs.Count; i++)
     {
         CatalogModel model = this.AllCatalogs[i];
         if (model.ParentId == null)
         {
             model.IsExpanded = true;
         }
         else
         {
             model.IsExpanded = false;
         }
     }
 }
Exemplo n.º 24
0
 public ActionResult UpdateGet(int id)
 {
     try
     {
         var model = new CatalogModel(_userRepository.GetCatalog(new catalog {
             id = id
         }));
         return(Json(new { err = true, view = RenderRazorViewToString(ControllerContext, "Update", model) }));
     }
     catch (Exception ex)
     {
         // chuyển sang page ERR
         return(RedirectToAction("Index", "Error"));
     }
 }
Exemplo n.º 25
0
        public IActionResult SaveCatalog(CatalogModel catalogModel)
        {
            var catalog = catalogModel.Id > 0 ? _catalogService.Get(catalogModel.Id) : new Catalog();

            if (catalog == null)
            {
                return(NotFound());
            }

            _modelMapper.Map(catalogModel, catalog);
            catalog.StoreIds = catalogModel.StoreIds;
            //save the catalog
            _catalogService.InsertOrUpdate(catalog);
            return(R.Success.Result);
        }
Exemplo n.º 26
0
        public async Task OnGet_ReturnPaginatedList(decimal PriceFrom,
                                                    decimal PriceTo, string searchString)
        {
            //Arrange
            var mockProductsRep = new Mock <IProductsRepository>();

            mockProductsRep.Setup(_db => _db.GetAllProducts()).Returns(MockProducts.GetAllProductsTest()); //настрока: вызов нужного метода и передача данных
            var pageModel = new CatalogModel(mockProductsRep.Object, new Mock <IMaterialsRepository>().Object, new Mock <IManufacturersRepostory>().Object);

            //Act
            var result = await pageModel.OnGetAsync(PriceFrom, PriceTo, SortState.NameAsc, null, null, 1, searchString);

            //Assert
            Assert.IsType <PaginatedList <Products> >(result);
        }
Exemplo n.º 27
0
 private void CreateTreeData(ObservableCollection <CatalogModel> allModels)
 {
     for (int i = 0; i < allModels.Count; i++)
     {
         CatalogModel model = allModels[i];
         ObservableCollection <CatalogModel> childs = new ObservableCollection <CatalogModel>();
         for (int j = 0; j < allModels.Count; j++)
         {
             CatalogModel child = allModels[j];
             if (child.ParentId == model.Id)
             {
                 model.Children.Add(child);
             }
         }
     }
 }
Exemplo n.º 28
0
        public bool Insert(CatalogModel model)
        {
            string     str = @"INSERT INTO [dbo].[Catalog] ([Name]) VALUES (@Name)";
            SqlCommand cmd = new SqlCommand(str, conn);

            cmd.Parameters.AddWithValue("Name", model.Name);

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch { return(false); }
            finally { cmd.Dispose(); conn.Close(); }
        }
Exemplo n.º 29
0
        public bool Update(CatalogModel model)
        {
            string     str = @"UPDATE [dbo].[Catalog] SET [Name] = @Name WHERE CatalogID = @id";
            SqlCommand cmd = new SqlCommand(str, conn);

            cmd.Parameters.AddWithValue("Name", model.Name);
            cmd.Parameters.AddWithValue("id", model.ID);
            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch { return(false); }
            finally { cmd.Dispose(); conn.Close(); }
        }
        public ICatalogAuthorizationService GetAuthorizationService(CatalogModel catalog)
        {
            switch (catalog.Type)
            {
            case CatalogType.OPDS:
                return(new HttpAuthorizationService(_webClient, _catalogRepository, catalog));

            case CatalogType.Litres:
                return(new LitresAuthorizationService(_webClient, _catalogRepository, catalog));

            case CatalogType.SkyDrive:
                return(new SkyDriveAuthorizationService(_liveLogin, _catalogRepository, catalog));
            }

            return(new DummyAuthorizationService());
        }