public bool AddProductToGroups(IEnumerable <ProductGroup> productGroups, int productID) { _productGroupRepository.DeleteMulti(x => x.ProductID == productID); foreach (var productGroup in productGroups) { _productGroupRepository.Add(productGroup); } return(true); }
public async Task UpdateProduct(ProductViewModel model) { var userId = _currentUser.GetUserId(); var product = await this._productRepository.Get(model.Id); product.Update(model.Name, Convert.ToDecimal(model.Weight), model.WeightPrefix, model.Description); var newProductImages = model.Images.Where(x => x.Id != Guid.Empty).ToList(); var existingimages = product.Images; foreach (var image in newProductImages) { var img = existingimages.FirstOrDefault(x => x.Id == image.Id); if (img == null) { product.AddImg(image.Id, image.FileName); } } var pModel = await _personalizedProductRepository.Get(userId, model.Id); if (pModel == null) { pModel = new PersonalizedProductModel(Guid.Empty, userId, model.Id); } pModel.Update(model.Category, model.Star, model.Wearable, model.Consumables); await this._productRepository.Update(product, pModel); //check if productCategory exist var categoryExist = await this._productGroupRepository.GetByName(userId, model.Category); if (categoryExist == null) { var newProductGroup = new ProductGroupModel(new Persistence.Entity.ProductGroupEntity { Id = Guid.NewGuid(), Name = model.Category, Maximized = true, Owner = userId }); await _productGroupRepository.Add(newProductGroup); } _messageService.SendMessage(new StringMessage($"PackListService:Update")); _messageService.SendMessage(new StringMessage($"ProductService:Update")); }
public async Task <Guid> UpsertProductGroupsExpandCollapse(Guid id, bool maximized, string name) { var newId = Guid.NewGuid(); if (id == Guid.Empty) { var model = new ProductGroupModel(new Persistence.Entity.ProductGroupEntity { Id = newId, Name = name, Owner = GetUserId(), Maximized = maximized }); await _productGroupRepository.Add(model); id = newId; } await _productGroupRepository.UpdateMaximized(id, maximized); _messageService.SendMessage(new StringMessage($"ProductService:Update")); return(id); }
public async Task Add(SystemDomains.ProductGroup.ProductGroup productGroup) { await _productGroupRepository.Add(productGroup); }
/// <summary> /// /// </summary> /// <param name="objProductGroup"></param> public void InsertProductGroup(ProductGroup objProductGroup) { _roleRepository.Add(objProductGroup); _unitOfWork.Commit(); }