public static string Save(DTO.Product product) { string message; using (client = new HttpClient { BaseAddress = new Uri(Properties.Settings.Default.ServerUrl) }) { HttpResponseMessage response; if (product.Id > 0) { response = client.PutAsJsonAsync("product", product).Result; } else { var serializedProduct = JsonConvert.SerializeObject(product); var content = new StringContent(serializedProduct, Encoding.UTF8, "application/json"); response = client.PostAsync("product", content).Result; } message = response.IsSuccessStatusCode ? "Operação realizada com sucesso!" : "Falha ao realizar a operação: " + response.StatusCode; } return(message); }
public DTO.ProductSize[] GetProductSizes(DTO.Product product, string filter) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.ArgumentWithinCondition(!product.IsNew(), "!product.IsNew()"); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can get all product sizes."); var query = Container .Get <IPersistentService>() .GetEntitySet <DataAccess.ProductSize>() .Where(ps => ps.ProductId == product.Id) .AsQueryable(); if (!string.IsNullOrWhiteSpace(filter)) { query = query.Where(ps => ps.Size.Name.Contains(filter)); } var dtoService = Container.Get <IDtoService>(); return (query .OrderBy(ps => ps.Size.Name) .ToArray() .Select(ps => dtoService.CreateProductSize(ps, false)) .ToArray()); }
public Product(DTO.Product product) { Id = product.Id.HasValue ? product.Id.Value : Guid.NewGuid(); Name = product.Name; Description = product.Description; Items = product.Items?.Select(x => new VO.ProductItem(x))?.ToList(); }
private int insertToDB() { DTO.Invoice invoice = new DTO.Invoice(); System.Collections.ArrayList details = new System.Collections.ArrayList(); for (int i = 0; i < grdItems.Rows.Count; i++) { DTO.InvoiceDetail d = new DTO.InvoiceDetail(); DTO.Product p = new DTO.Product(); p.Productid = int.Parse(grdItems.Rows[i].Cells[7].Value.ToString()); d.Quantity = int.Parse(grdItems.Rows[i].Cells[2].Value.ToString()); d.Priceout = decimal.Parse(grdItems.Rows[i].Cells[3].Value.ToString()); d.Dicount = decimal.Parse(grdItems.Rows[i].Cells[4].Value.ToString()); d.Pricein = decimal.Parse(grdItems.Rows[i].Cells[8].Value.ToString()); d.Product = p; details.Add(d); } DTO.Member member = new DTO.Member(); member.Memberid = (int)cboMember.SelectedValue; /// invoice.Staff = UserSession.Session.Staff; invoice.Member = member; invoice.Remark = ""; invoice.Discount = decimal.Parse(txtDiscount.Text.Replace("%", "").Replace(" ","")); invoice.InvoiceDetail = details; return new DAO.InvoiceDAO().addInvoice(invoice); }
public ProductSize[] GetProductSizes(DTO.Product product, string filter) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductSizesByProduct(product, filter))); }
public static DTO.Order_Item ToDTO(this Models.OrderItem oi) { DTO.Product product = new DTO.Product(); return(new DTO.Order_Item { id = oi.Id, product = oi.ProductId, quantity = oi.Quantity, }); }
public Product ToDatabaseModel(DTO.Product p) { return(new Product { Id = Guid.Parse(p.Id), Name = p.Name, Description = p.Description, Price = p.Price }); }
public static Models.Product ToDatabaseModel(this DTO.Product p) { return(new Models.Product { Id = p.Id, Name = p.Name, Price = p.Price, Description = p.Description }); }
protected override void SetDtoToControls(DTO.Product product) { _nameTextBox.Text = product.Name; _activeCheckBox.Checked = product.Active; _subCategoryReferenceEditor.Dto = product.SubCategory; _brandReferenceEditor.Dto = product.Brand; _descriptionTextBox.Text = product.Description; _vendorURLWatermarkedTextBox.Text = product.VendorShopURL; _previewPicture.SetURLs(product.PreviewPictureURL, product.FullPictureURL); }
protected override void SetControlsToDto(DTO.Product product) { product.Name = _nameTextBox.Text; product.Active = _activeCheckBox.Checked; product.SubCategory = _subCategoryReferenceEditor.Dto; product.Brand = _brandReferenceEditor.Dto; product.Description = _descriptionTextBox.Text; product.VendorShopURL = _vendorURLWatermarkedTextBox.Text; product.PreviewPictureURL = _previewPicture.PreviewPictureURL; product.FullPictureURL = _previewPicture.FullPictureURL; }
public static Models.Product ToDatabaseModel(this DTO.Product product) { return(new Models.Product { Id = product.Id, Name = product.name, Price = product.price, Merchant_id = product.merchant_id, Status = product.status, Created_at = product.created_at, }); }
public string UpdateProduct(DTO.Product product) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); var errors = IoC.Container.Get <IValidateService>().Validate(product); if (errors != null) { return(errors.ToErrorMessage()); } return(APIClientHelper <ProductAPIClient> .Call(c => c.UpdateProduct(product))); }
public void CreateProduct(DTO.Product createdProduct) { CheckHelper.ArgumentNotNull(createdProduct, "createdProduct"); CheckHelper.ArgumentWithinCondition(createdProduct.IsNew(), "Product is not new."); Container.Get<IValidateService>().CheckIsValid(createdProduct); CheckHelper.ArgumentWithinCondition(!createdProduct.SubCategory.IsNew(), "SubCategory of Product is new."); CheckHelper.ArgumentWithinCondition(!createdProduct.Brand.IsNew(), "Brand of Product is new."); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can create product."); var persistentService = Container.Get<IPersistentService>(); var subCategory = persistentService.GetEntityById<SubCategory>(createdProduct.SubCategory.Id); CheckHelper.NotNull(subCategory, "SubCategory does not exist."); var brand = persistentService.GetEntityById<DataAccess.Brand>(createdProduct.Brand.Id); CheckHelper.NotNull(brand, "Brand does not exist."); var httpService = Container.Get<IHttpService>(); var product = new DataAccess.Product { Name = createdProduct.Name, SubCategoryId = subCategory.Id, SubCategory = subCategory, BrandId = brand.Id, Brand = brand, Active = brand.Active, Description = createdProduct.Description, VendorShopURL = createdProduct.VendorShopURL, FullPictureURL = httpService.GetRelativeURLFromAbsoluteURL(createdProduct.FullPictureURL), PreviewPictureURL = httpService.GetRelativeURLFromAbsoluteURL(createdProduct.PreviewPictureURL) }; product.UpdateTrackFields(Container); persistentService.Add(product); persistentService.SaveChanges(); createdProduct.Id = product.Id; createdProduct.CreateDate = product.CreateDate; createdProduct.CreateUser = product.CreatedBy.GetFullName(); createdProduct.ChangeDate = product.ChangeDate; createdProduct.ChangeUser = product.ChangedBy.GetFullName(); }
public DTO.Product GetProduct(int id) { using (var db = new LNBagShopDBEntities()) { DTO.Product product = null; DataAccessLayer.Product dbProduct = db.Products.Find(id); if (dbProduct != null) { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); product = mapper.Map <DataAccessLayer.Product, DTO.Product>(dbProduct); } return(product); } }
protected override object[] GetMasterDtoValues(DTO.Product product) { var values = new object[] { product.Name, product.SubCategory.ToString(), product.Brand.ToString(), product.Description, product.VendorShopURL, product.Active.ToYesNo() }; return (values .Concat(TrackableDtoListFormHelper.GetValues(product)) .ToArray()); }
public static DTO.Product GetById(int Id) { DTO.Product product = null; using (client = new HttpClient { BaseAddress = new Uri(Properties.Settings.Default.ServerUrl) }) { HttpResponseMessage response = client.GetAsync("product/" + Id).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; product = JsonConvert.DeserializeObject <DTO.Product>(jsonString); } return(product); } }
public FormProductForm(FormProduct formProduct, int Id = 0) { InitializeComponent(); this.formProduct = formProduct; this.tbId.Enabled = false; productComponents = null; try { if (Id > 0) { DTO.Product product = ProductCtrl.GetById(Id); this.tbId.Text = Id.ToString(); tbName.Text = product.Name; tbDescription.Text = product.Description; tbAmount.Text = product.Amount.ToString(); tbPrice.Text = product.Price.ToString("0.00"); this.tbId.ReadOnly = true; productComponents = (from component in product.Components select component.Id).ToList(); } componentsList = ComponentCtrl.GetAll(); foreach (var component in componentsList) { clbComponents.Items.Add(component.Name, productComponents != null && productComponents.Contains(component.Id)); } this.tbName.Select(); } catch (AggregateException ex) { MessageBox.Show("Aplicação servidora não responde: " + ex.Message); } catch (Exception ex) { MessageBox.Show("Problema na solicitação: " + ex.Message); } }
public string CreateProduct(DTO.Product product) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); var errors = IoC.Container.Get <IValidateService>().Validate(product); if (errors != null) { return(errors.ToErrorMessage()); } var createdProduct = (DTO.Product)product.Clone(); var errorMessage = APIClientHelper <ProductAPIClient> .Call(c => c.CreateProduct(ref createdProduct)); product.Id = createdProduct.Id; return(errorMessage); }
public DTO.Product CreateProduct(DataAccess.Product product, bool includeOnlyActive = true) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.ArgumentWithinCondition(!product.IsNew(), "!product.IsNew()"); return (_dtoCache.Get( product, p => { var httpService = Container.Get <IHttpService>(); var result = new DTO.Product { Id = p.Id, Name = p.Name, Description = p.Description, PreviewPictureURL = httpService.GetAbsoluteURLFromRelativeURL(p.PreviewPictureURL), FullPictureURL = httpService.GetAbsoluteURLFromRelativeURL(p.FullPictureURL), VendorShopURL = p.VendorShopURL, Active = p.Active }; CopyTrackableFields(result, p); return result; }, (pDto, p) => { pDto.Brand = CreateBrand(p.Brand, includeOnlyActive); pDto.SubCategory = CreateSubCategory(p.SubCategory, includeOnlyActive); pDto.ProductSizes = p.ProductSizes .Where(ps => ps.Active || !includeOnlyActive) .OrderBy(ps => ps.Size.Name) .Select(ps => CreateProductSize(ps, includeOnlyActive)) .ToArray(); })); }
public void UpdateProduct_Should_Throw_Exception_When_Current_User_Is_Not_Seller() { // Arrange var container = ContainerMockFactory.Create(); var securityService = container.Get <ISecurityService>(); securityService.LogIn(UserMockFactory.Olesya.Login, EncryptServiceMockFactory.OlesyaPasswordData.Password); const string NEW_PRODUCT_NAME = "New Product"; const string NEW_PRODUCT_DESCRIPTION = "New Description"; const string NEW_PRODUCT_FULL_PICTURE_URL = "Images/full_g9e8ryg89rygyg89rey.jpg"; const string NEW_PRODUCT_PREVIEW_PICTURE_URL = "Images/preview_g9e8ryg89rygyg89rey.jpg"; const string NEW_PRODUCT_VENDOR_SHOP_URL = "http://www.carters.com/carters/Surf-Sunglasses/V_24960,default,pd.html?dwvar_V__24960_color=Gray&cgid=carters-toddler-boy-swim-shop-sunglasses&start="; var brand = container.Get <IDtoService>().CreateBrand(BrandMockFactory.Carters); var subCategory = container.Get <IDtoService>().CreateSubCategory(SubCategoryMockFactory.Boys_2_5); var updatedProduct = new DTO.Product { Id = ProductMockFactory.TheChildrensPlace_Girls_Shorts.Id, Name = NEW_PRODUCT_NAME, Active = true, Description = NEW_PRODUCT_DESCRIPTION, PreviewPictureURL = HttpServiceMockFactory.APPLICATION_URL + NEW_PRODUCT_PREVIEW_PICTURE_URL, FullPictureURL = HttpServiceMockFactory.APPLICATION_URL + NEW_PRODUCT_FULL_PICTURE_URL, VendorShopURL = NEW_PRODUCT_VENDOR_SHOP_URL, Brand = brand, SubCategory = subCategory }; var productService = container.Get <IProductService>(); // Act // Assert ExceptionAssert.Throw <InvalidOperationException>( () => productService.UpdateProduct(updatedProduct), "Only seller can change product."); }
public void UpdateProduct(DTO.Product updatedProduct) { CheckHelper.ArgumentNotNull(updatedProduct, "updatedProduct"); CheckHelper.ArgumentWithinCondition(!updatedProduct.IsNew(), "Product is new."); Container.Get<IValidateService>().CheckIsValid(updatedProduct); CheckHelper.ArgumentWithinCondition(!updatedProduct.SubCategory.IsNew(), "SubCategory of Product is new."); CheckHelper.ArgumentWithinCondition(!updatedProduct.Brand.IsNew(), "SubCategory of Product is new."); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can change product."); var persistentService = Container.Get<IPersistentService>(); var product = persistentService.GetEntityById<DataAccess.Product>(updatedProduct.Id); CheckHelper.NotNull(product, "Product does not exist."); var subCategory = persistentService.GetEntityById<SubCategory>(updatedProduct.SubCategory.Id); CheckHelper.NotNull(subCategory, "SubCategory does not exist."); var brand = persistentService.GetEntityById<DataAccess.Brand>(updatedProduct.Brand.Id); CheckHelper.NotNull(brand, "Brand does not exist."); var httpService = Container.Get<IHttpService>(); product.Name = updatedProduct.Name; product.Active = updatedProduct.Active; product.SubCategoryId = subCategory.Id; product.SubCategory = subCategory; product.BrandId = brand.Id; product.Brand = brand; product.Description = updatedProduct.Description; product.VendorShopURL = updatedProduct.VendorShopURL; product.FullPictureURL = httpService.GetRelativeURLFromAbsoluteURL(updatedProduct.FullPictureURL); product.PreviewPictureURL = httpService.GetRelativeURLFromAbsoluteURL(updatedProduct.PreviewPictureURL); product.UpdateTrackFields(Container); persistentService.SaveChanges(); }
protected override string OnInsert(DTO.Product product) { return(IoCContainer.Get <IProductService>().CreateProduct(product)); }
public ProductEditForm(EditFormMode mode, DTO.Product product) : base(mode, product) { InitializeComponent(); }
private void btnSave_Click(object sender, EventArgs e) { DTO.Product product = new DTO.Product(); if (tbId.Text != "") { product.Id = Convert.ToInt32(tbId.Text); } else { string hostName = Dns.GetHostName(); IPAddress[] ip = Dns.GetHostAddresses(hostName); product.Ip = ip[1].ToString(); } string validationMessage = ""; if (tbName.Text.Trim() == "") { validationMessage += "Nome do produto é obrigatório. "; } int amount; if (!int.TryParse(tbAmount.Text, out amount)) { validationMessage += "Quantidade deve ser inteiro. "; } double price; if (!double.TryParse(tbPrice.Text, out price)) { validationMessage += "Preço inválido!"; } if (validationMessage == "") { product.Name = tbName.Text; product.Description = tbDescription.Text; product.Amount = amount; product.Price = price; if (clbComponents.Items.Count > 0) { List <DTO.Component> productComponents = new List <DTO.Component>(); int quantityOfComponentsChecked = clbComponents.Items.Count; for (int i = 0; i < quantityOfComponentsChecked; i++) { if (clbComponents.GetItemChecked(i)) { productComponents.Add(new DTO.Component() { Id = componentsList[i].Id }); } } product.Components = productComponents; } try { string message = ProductCtrl.Save(product); this.formProduct.UpdateDgvProducts(); MessageBox.Show(message); this.Close(); } catch (AggregateException ex) { MessageBox.Show("Operação não realizada porque a aplicação servidora não responde: " + ex.Message); } catch (Exception ex) { MessageBox.Show("Operação não realizada. Problema na solicitação: " + ex.Message); } } else { MessageBox.Show(validationMessage); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { string productName = txtName.Text.Trim(), productCode = txtProductCode.Text.Trim(), price = txtPrice.Text.Trim(), quantity = txtQuantity.Text.Trim(), imgURL = Request.Form.Get("ctl00$ContentPlaceHolder$txtImgURL").Trim(), content = txtDetail.Text.Trim(), summary = txtSummary.Text.Trim(), numShip = txtNumShip.Text.Trim(), amountSale = txtAmountSale.Text.Trim(), quatitySale = txtQuantity.Text.Trim(); bool freeShp = radFreeShip.Checked, isSale = chkSale.Checked; Guid manuID = Guid.Parse(txtNhaSX.SelectedValue), oriID = Guid.Parse(txtXuatXu.SelectedValue); int outTmp; if (productName.Equals(string.Empty)) { txtName.Focus(); throw new Exception("Tên sản phẩm không được để trống"); } if (productCode.Equals(string.Empty)) { txtProductCode.Focus(); throw new Exception("Mã sản phẩm không được để trống"); } if (imgURL.Equals(string.Empty)) { throw new Exception("Ảnh sản phẩm không được để trống"); } if (price.Equals(string.Empty) || !int.TryParse(price, out outTmp)) { txtPrice.Focus(); throw new Exception("Giá sản phẩm không được để trống và định dạnh số nguyên"); } if (quantity.Equals(string.Empty) || !int.TryParse(quantity, out outTmp)) { txtQuantity.Focus(); throw new Exception("Số lượng sản phẩm không được để trống và định dạnh số nguyên"); } if (!freeShp && numShip.Equals(string.Empty) && !int.TryParse(numShip, out outTmp)) { txtNumShip.Focus(); throw new Exception("Số lượng tối thiểu sản phẩm mua để được miễn phí ship không được để trống và đúng định dạng số nguyên"); } if (isSale) { if (amountSale.Equals(string.Empty) || !int.TryParse(amountSale, out outTmp)) { txtAmountSale.Focus(); throw new Exception("Số lượng tiền giảm khuyến mại không được để trống"); } if (quatitySale.Equals(string.Empty) || !int.TryParse(quatitySale, out outTmp)) { txtQuantitySale.Focus(); throw new Exception("Số lượng sản phẩm mua để đạt được khuyến mại không được để trống và đúng định dạng số nguyên"); } } DTO.Product product = new DTO.Product(); product.ProductID = Guid.NewGuid(); product.ProductName = productName; product.Price = int.Parse(price); product.Quantity = int.Parse(quantity); product.ManufacturerID = manuID; product.OriginID = oriID; product.ProductCode = productCode; product.Image = imgURL.Substring(imgURL.LastIndexOf("/") + 1, imgURL.Length - imgURL.LastIndexOf("/") - 1); product.Content = HttpUtility.UrlEncode(content); product.Summary = HttpUtility.UrlEncode(summary); product.Ship = freeShp ? 0 : int.Parse(numShip); product.IsSale = isSale; if (isSale) { product.AmountSale = int.Parse(amountSale); product.QuantitySale = int.Parse(quatitySale); } List <Guid> categories = new List <Guid>(); foreach (ListItem item in ckCategory.Items) { if (item.Selected) { categories.Add(Guid.Parse(item.Value)); } } new Product_BUS().InsertProduct(product, categories); Response.Write("<script>alert('Thêm thành công')</script>"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "')</script>"); } }
private DTO.Product[] MakeProductArray(IList productList) { if(productList != null) { DTO.Product[] products = new DTO.Product[productList.Count]; IEnumerator prodEnum = productList.GetEnumerator(); for(int i = 0; i < productList.Count; i++) { prodEnum.MoveNext(); products[i] = DTO.DTOAssembler.AssembleProduct((DomainModel.Product)prodEnum.Current); } return products; } return null; }
protected override string OnUpdate(DTO.Product product) { return(IoCContainer.Get <IProductService>().UpdateProduct(product)); }
private void btnSave_Click(object sender, EventArgs e) { if (id == 0) { if ( txtBarcode.Text.Trim() == "" || txtProductCode.Text.Trim() == "" || txtName.Text.Trim() == "" // || cboCategory.SelectedValue == "" || txtPriceIn.Text.Trim() == "" || txtPriceOut.Text.Trim() == "" ) { MessageBox.Show("សូមបំពេញពត៏មានឲ្យបានត្រឹមត្រូវ!!!"); } else { DAO.ProductDAO productDAO = new DAO.ProductDAO(); if (productDAO.checkProduct(txtProductCode.Text)) { MessageBox.Show("លេខកូដទំនិញរបស់លោកអ្នកមានរួចហើយ សូមបញ្ចូលលេខកូដទំនិញផ្សេង"); return; } DTO.Staff staff = new DTO.Staff(); staff.Staffid = UserSession.Session.Staff.Staffid;// Data.user.Staffid; DTO.Category cate = new DTO.Category(); cate.Categoryid = (int)cboCategory.SelectedValue; DTO.Product product = new DTO.Product(0,txtProductCode.Text.Trim(), txtBarcode.Text.Trim(), txtName.Text.Trim(), txtDescription.Text.Trim(), Decimal.Parse(txtPriceIn.Text.Trim()), Decimal.Parse(txtPriceOut.Text.Trim()), txtRemark.Text.Trim(), staff, staff, cate); if (new DAO.ProductDAO().addProduct(product)) { ClearForm(); dgvProduct.DataSource = new DAO.ProductDAO().getAllProductDS().Tables[0]; id = 0; } else { MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!"); } } } else { if (txtBarcode.Text.Trim() == "" || txtProductCode.Text.Trim() == "" || txtName.Text.Trim() == "" // || cboCategory.SelectedValue == "" || txtPriceIn.Text.Trim() == "" || txtPriceOut.Text.Trim() == "" ) { MessageBox.Show("សូមបំពេញពត៏មានឲ្យបានត្រឹមត្រូវ!!!"); } else { DTO.Staff staff = new DTO.Staff(); staff.Staffid = UserSession.Session.Staff.Staffid;// Data.user.Staffid; DTO.Category cate = new DTO.Category(); cate.Categoryid = (int)cboCategory.SelectedValue; DTO.Product product = new DTO.Product(id, txtProductCode.Text.Trim(), txtBarcode.Text.Trim(), txtName.Text.Trim(), txtDescription.Text.Trim(), Decimal.Parse(txtPriceIn.Text.Trim()), Decimal.Parse(txtPriceOut.Text.Trim()), txtRemark.Text.Trim(), staff, staff, cate); if (new DAO.ProductDAO().updateProduct(product)) { ClearForm(); dgvProduct.DataSource = new DAO.ProductDAO().getAllProductDS().Tables[0]; id = 0; delete.Visible = false; } else { MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!"); } } } }
public ProductMasterDetailForm(ListFormMode mode, DTO.Product product) : base(mode, product) { InitializeComponent(); }
protected override ProductSize[] LoadDetailDtosByFilter(string filter, DTO.Product product) { return(IoCContainer.Get <IProductService>().GetProductSizes(product, filter)); }
public void UpdateProduct_Should_Update_Product() { // Arrange var container = ContainerMockFactory.Create(); var securityService = container.Get <ISecurityService>(); securityService.LogIn(UserMockFactory.Diana.Login, EncryptServiceMockFactory.DianaPasswordData.Password); const string NEW_PRODUCT_NAME = "New Product"; const string NEW_PRODUCT_DESCRIPTION = "New Description"; const string NEW_PRODUCT_FULL_PICTURE_URL = "Images/full_g9e8ryg89rygyg89rey.jpg"; const string NEW_PRODUCT_PREVIEW_PICTURE_URL = "Images/preview_g9e8ryg89rygyg89rey.jpg"; const string NEW_PRODUCT_VENDOR_SHOP_URL = "http://www.carters.com/carters/Surf-Sunglasses/V_24960,default,pd.html?dwvar_V__24960_color=Gray&cgid=carters-toddler-boy-swim-shop-sunglasses&start="; var createDate = ProductMockFactory.TheChildrensPlace_Girls_Shorts.CreateDate; var createdBy = ProductMockFactory.TheChildrensPlace_Girls_Shorts.CreatedBy; var brand = container.Get <IDtoService>().CreateBrand(BrandMockFactory.Carters); var subCategory = container.Get <IDtoService>().CreateSubCategory(SubCategoryMockFactory.Boys_2_5); var updatedProduct = new DTO.Product { Id = ProductMockFactory.TheChildrensPlace_Girls_Shorts.Id, Name = NEW_PRODUCT_NAME, Active = true, Description = NEW_PRODUCT_DESCRIPTION, PreviewPictureURL = HttpServiceMockFactory.APPLICATION_URL + NEW_PRODUCT_PREVIEW_PICTURE_URL, FullPictureURL = HttpServiceMockFactory.APPLICATION_URL + NEW_PRODUCT_FULL_PICTURE_URL, VendorShopURL = NEW_PRODUCT_VENDOR_SHOP_URL, Brand = brand, SubCategory = subCategory }; var productService = container.Get <IProductService>(); var persistentService = container.Get <IPersistentService>(); var timeService = container.Get <ITimeService>(); // Act productService.UpdateProduct(updatedProduct); // Assert var actualProduct = persistentService.GetEntityById <DataAccess.Product>(ProductMockFactory.TheChildrensPlace_Girls_Shorts.Id); Assert.AreEqual(NEW_PRODUCT_NAME, actualProduct.Name); Assert.IsTrue(actualProduct.Active); Assert.AreEqual(NEW_PRODUCT_DESCRIPTION, actualProduct.Description); Assert.AreEqual(NEW_PRODUCT_PREVIEW_PICTURE_URL, actualProduct.PreviewPictureURL); Assert.AreEqual(NEW_PRODUCT_FULL_PICTURE_URL, actualProduct.FullPictureURL); Assert.AreEqual(NEW_PRODUCT_VENDOR_SHOP_URL, actualProduct.VendorShopURL); Assert.AreEqual(SubCategoryMockFactory.Boys_2_5.Id, actualProduct.SubCategory.Id); Assert.AreEqual(SubCategoryMockFactory.Boys_2_5.Name, actualProduct.SubCategory.Name); Assert.AreEqual(SubCategoryMockFactory.Boys_2_5.Active, actualProduct.SubCategory.Active); Assert.AreEqual(BrandMockFactory.Carters.Id, actualProduct.Brand.Id); Assert.AreEqual(BrandMockFactory.Carters.Name, actualProduct.Brand.Name); Assert.AreEqual(BrandMockFactory.Carters.Active, actualProduct.Brand.Active); Assert.AreEqual(createDate, actualProduct.CreateDate); Assert.AreEqual(timeService.UtcNow, actualProduct.ChangeDate); Assert.AreEqual(createdBy, actualProduct.CreatedBy); Assert.AreEqual(UserMockFactory.Diana, actualProduct.ChangedBy); Assert.AreEqual(updatedProduct, container.Get <IDtoService>().CreateProduct(actualProduct)); }