public static void UpdateSize(Size size) { SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateSize]", CommandType.StoredProcedure, new SqlParameter("@SizeId", size.SizeId), new SqlParameter("@SizeName", size.SizeName), new SqlParameter("@SortOrder", size.SortOrder) ); }
public static int AddSize(Size size) { if (size == null) throw new ArgumentNullException("size"); return SQLDataAccess.ExecuteScalar<int>("[Catalog].[sp_AddSize]", CommandType.StoredProcedure, new SqlParameter("@SizeName", size.SizeName), new SqlParameter("@SortOrder", size.SortOrder) ); }
public static void OffersFromString(Product product, string offersString) { product.HasMultiOffer = true; var oldOffers = new List<Offer>(product.Offers); product.Offers.Clear(); var mainOffer = true; foreach (string[] fields in offersString.Split(';').Select(str => str.Replace("[", "").Replace("]", "").Split(':'))) { if (fields.Count() == 6) { var multiOffer = oldOffers.FirstOrDefault(offer => offer.ArtNo == fields[0]) ?? new Offer(); multiOffer.ProductId = product.ProductId; multiOffer.Main = mainOffer; multiOffer.ArtNo = fields[0]; // ArtNo if (fields[1] != "null") // Size { Size size = SizeService.GetSize(fields[1]); if (size == null) { size = new Size { SizeName = fields[1] }; size.SizeId = SizeService.AddSize(size); } multiOffer.SizeID = size.SizeId; } if (fields[2] != "null") // Color { Color color = ColorService.GetColor(fields[2]); if (color == null) { color = new Color { ColorName = fields[2], ColorCode = "#000000" }; color.ColorId = ColorService.AddColor(color); } multiOffer.ColorID = color.ColorId; } multiOffer.Price = fields[3].TryParseFloat(); // Price multiOffer.SupplyPrice = fields[4].TryParseFloat(); // SupplyPrice multiOffer.Amount = fields[5].TryParseFloat(); //Amount product.Offers.Add(multiOffer); mainOffer = false; } } }