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()), }); }
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)); }
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)); }
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(); } } }
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); }
public ActionResult Create(CatalogModel catalogmodel) { if (ModelState.IsValid) { db.Catalogs.Add(catalogmodel); catalogmodel.CreateTime = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalogmodel)); }
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)); }
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."); } }
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)); }
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); } }
public IActionResult Index() { var cart = _checkoutService.GetCart(); var catalog = _shoppingContext.Catalog.ToList(); var model = new CatalogModel { CartId = cart.Id, Catalog = catalog }; return(View(model)); }
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; }
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(); }
/// <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(); }
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)); } }
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); } }
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); } }
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)); }
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)); }
/// <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; } } }
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")); } }
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); }
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); }
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); } } } }
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(); } }
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()); }