public ActionResult Create(ProductInfo pro) { if (ModelState.IsValid) { ProductInfo product = new ProductInfo(); if (pro.ColorId != null) { product.ColorId = pro.ColorId; } product.Price = pro.Price; if (pro.SizeId != null) { product.SizeId = pro.SizeId; } product.SalePercent = pro.SalePercent; if (pro.SaleBannerId != null) { product.SaleBannerId = pro.SaleBannerId; } product.ProductId = pro.ProductId; product.isTopSelling = pro.isTopSelling; product.isNew = pro.isNew; product.Quantity = pro.Quantity; product.CreateDate = DateTime.Now; db.ProductInfos.Add(product); db.SaveChanges(); foreach (HttpPostedFileBase image in pro.ImageFile) { string imgName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + image.FileName; string imgPath = Path.Combine(Server.MapPath("~/Uploads/Product/"), imgName); image.SaveAs(imgPath); ProductImages img = new ProductImages(); img.Name = imgName; img.ProductInfoId = product.Id; db.ProductImages.Add(img); db.SaveChanges(); } for (int i = 0; i < pro.SizeOptKey.Length; i++) { SizeOption option = new SizeOption(); option.productInfoId = product.Id; option.Key = pro.SizeOptKey[i]; option.Value = pro.SizeOptValue[i]; db.SizeOption.Add(option); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.Product = db.Product.ToList(); ViewBag.Color = db.Colors.ToList(); ViewBag.Size = db.Size.ToList(); ViewBag.Sale = db.SaleBanner.ToList(); return(View(pro)); }
private static IEnumerable <int> GetSizes(SizeOption option) { if (option == SizeOption.Application) { return new[] { 256, 128, 64, 48, 32, 24, 16 } } ; return(new[] { 256, 128, 96, 64, 48, 40, 32, 24, 22, 20, 16, 14, 10, 8 }); }
public static void Save(Image image, Stream stream, SizeOption option = SizeOption.Application, bool dispose = false) { if (image == null) { throw new ArgumentNullException(nameof(image)); } if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var img = default(Image); try { img = ImageCorrection(image); var imgs = ImageCorrection(GetSizes(option).Where(x => img.Width >= x).Select(x => img.Redraw(x, x))); Save(imgs, stream, dispose); } finally { if (dispose) { img?.Dispose(); } } }
public ActionResult DeleteConfirmed(int id) { SizeOption sizeOption = db.SizeOption.Find(id); db.SizeOption.Remove(sizeOption); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Key,Value")] SizeOption sizeOption) { if (ModelState.IsValid) { db.Entry(sizeOption).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sizeOption)); }
public ActionResult Create([Bind(Include = "Id,Key,Value")] SizeOption sizeOption) { if (ModelState.IsValid) { db.SizeOption.Add(sizeOption); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sizeOption)); }
// GET: Admin/SizeOptions/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SizeOption sizeOption = db.SizeOption.Find(id); if (sizeOption == null) { return(HttpNotFound()); } return(View(sizeOption)); }
public InvoicerApi( SizeOption size = SizeOption.A4, OrientationOption orientation = OrientationOption.Portrait, string currency = "£" ) { Invoice = new Invoice(); Invoice.Title = "Invoice"; Invoice.PageSize = size; Invoice.PageOrientation = orientation; Invoice.Currency = currency; Invoice.BillingDate = DateTime.Now; Invoice.DueDate = Invoice.BillingDate.AddDays(14); Invoice.Reference = DefaultReference; }
// /// <summary> /// Set the size of text popup based on editor setting /// </summary> /// <param name="sizeOption">Size option (FixedPopupSize/FixedFontSize)</param> /// <param name="popUpsize">Size of the popup</param> /// <param name="fontSizeTitle">Font size of Title</param> /// <param name="fontSizeBody">Font size of message</param> /// <param name="margin">Padding around text</param> /// <returns></returns> IEnumerator SetSize(TextPopUpDataModel textPopUpDataModel, SizeOption sizeOption) { contentRect.GetComponent <ContentSizeFitter>().enabled = false; //int margin = textPopUpDataModel.popUpSetting.margin; contentRect.GetComponent <VerticalLayoutGroup>().padding = textPopUpDataModel.popUpSetting.padding;//new RectOffset(margin, margin, margin, margin); switch (sizeOption) { case SizeOption.FixedPopupSize: //font size will be reset according to the popup size SetContentSize(size); txtTitle.fontSize = textPopUpDataModel.popUpSetting.title.size; yield return(null); txtTitle.GetComponent <LayoutElement>().minHeight = txtTitle.textBounds.size.y; txtBody.enableAutoSizing = true; break; case SizeOption.FixedContentSize: //font size will be fixed but popup size will be changed accordingly contentRect.GetComponent <ContentSizeFitter>().enabled = true; yield return(new WaitForEndOfFrame()); SetContentSize(contentRect.GetComponent <RectTransform>().sizeDelta); break; case SizeOption.FixedPercentage: //popup size will be based on Percentage var rect = transform.GetComponentInParent <Canvas>().GetComponent <RectTransform>().sizeDelta; float height = rect.y * ((float)textPopUpDataModel.popUpSetting.percentage / 100.0f); float width = (rect.x / rect.y) * height - 100; //100 referes control panel width size = new Vector2(width, height); StartCoroutine(SetSize(textPopUpDataModel, SizeOption.FixedPopupSize)); // call SetSize to fit text into new size of popup break; } yield return(new WaitForEndOfFrame()); PlacePopUp(rectTransform); }
private void CreateMaterialCount(SizeOption option) { List <Material> materials = CommonClientFunctions.ReadMaterials(); var materialCount = CreateMaterialCount(materials); if (materialCount is null) { return; } materialCount.SizeOptionId = option.Id; option.MaterialCounts.Add(materialCount); using var db = new ShopContext(); new DataService(db).Create(materialCount); }
public InvoiceSharpApi( SizeOption size = SizeOption.A4, OrientationOption orientation = OrientationOption.Portrait, string currency = "€" ) { Invoice = new Invoice(); Invoice.Title = "Facture"; Invoice.PageSize = size; Invoice.PageOrientation = orientation; Invoice.Currency = currency; Invoice.InvoiceDate = DateTime.Now; Invoice.OrderReference = DefaultReference; Invoice.IsUnpaid = false; Invoice.UnpaidMessage = "à payer"; Invoice.PaidMessage = "payée"; }
public InvoicerApi( long IdVenta, DateTime f, SizeOption size = SizeOption.A4, OrientationOption orientation = OrientationOption.Portrait, string currency = "$" ) { Invoice = new Invoice { Title = "Ticket de venta", PageSize = size, PageOrientation = orientation, Currency = currency, BillingDate = f }; Invoice.DueDate = Invoice.BillingDate.AddDays(14); Invoice.Reference = IdVenta.ToString(); }
private void DeleteMaterialCount(SizeOption option) { var materialCounts = CommonClientFunctions.ReadMaterialCountsBySizeOptionId(option.Id); var hasElements = CommonClientFunctions.EntitySelection(materialCounts, out MaterialCount materialCount, 1); if (!hasElements) { Console.WriteLine("No Material Counts Available"); return; } if (materialCount is null) { return; } using (var db = new ShopContext()) { new DataService(db).Delete(materialCount); } }
/// <summary> /// Saves multiple sizes of the specified <see cref="Image"/> to a single <see cref="Icon"/> file. /// </summary> /// <param name="image"> /// The images to be converted into a single icon. /// </param> /// <param name="path"> /// The file path to the icon. /// </param> /// <param name="option"> /// The option for determining automatic resizing. /// </param> /// <exception cref="ArgumentNullException"> /// image or path is null. /// </exception> /// <exception cref="ArgumentException"> /// path is invalid. /// </exception> public static void Save(Image image, string path, SizeOption option = SizeOption.Application) { if (image == null) { throw new ArgumentNullException(nameof(image)); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } var file = PathEx.Combine(path); if (!PathEx.IsValidPath(file)) { throw new ArgumentException(); } if (!FileEx.TryDelete(file)) { return; } using (var fs = new FileStream(file, FileMode.Create)) Save(image, fs, option, true); }
private void EditMaterialCount(SizeOption option) { var materialCounts = option.MaterialCounts; var hasElements = CommonClientFunctions.EntitySelection(materialCounts, out MaterialCount materialCount, 1); if (!hasElements) { Console.WriteLine("No Material Counts Available"); return; } if (materialCount is null) { return; } Console.Write($"Description ({materialCount.Description})> "); string newDescription = Console.ReadLine(); Console.Write($"Count ({materialCount.MaterialUnitCount})> "); var pInput = Console.ReadLine(); if (String.IsNullOrWhiteSpace(pInput)) { pInput = "-1"; } Decimal.TryParse(pInput, out decimal newCount); materialCount.MaterialUnitCount = newCount == -1 ? materialCount.MaterialUnitCount : newCount; materialCount.Description = String.IsNullOrWhiteSpace(newDescription) ? materialCount.Description : newDescription; using (var db = new ShopContext()) { new DataService(db).Update(materialCount); } }
/// <summary> /// Converts this numeric value into a string that represents the number expressed as a size /// value in the specified <see cref="SizeUnit"/>. /// </summary> /// <param name="value"> /// The value to be converted. /// </param> /// <param name="unit"> /// The new unit. /// </param> /// <param name="binary"> /// true for the binary numeral system; otherwise, false for the decimal numeral system. /// </param> /// <param name="suffix"> /// true to show the size unit suffix; otherwise, false. /// </param> /// <param name="sizeOptions"> /// </param> public static string FormatSize(this long value, SizeUnit unit, bool binary = true, bool suffix = true, SizeOption sizeOptions = SizeOption.None) { if (value < 0) { return($"-{Math.Abs(value).FormatSize(unit, binary, suffix, sizeOptions)}"); } var f = sizeOptions != SizeOption.None ? "0.##" : "0.00"; if (value == 0) { return($"{value.ToString(f, CultureConfig.GlobalCultureInfo)} bytes"); } var d = value / Math.Pow(binary ? 1024 : 1000, (int)unit); if (sizeOptions == SizeOption.Round) { d = Math.Round(d); } var s = d.ToString(f, CultureConfig.GlobalCultureInfo); if (!suffix) { return(s); } s = $"{s} {unit}"; if (unit == 0 && !Math.Abs(d).Equals(1d)) { s += "s"; } return(s); }
/// <summary> /// Set the size of QandA popup based on editoer setting /// </summary> /// <param name="sizeOption">Size option (FixedPopupSize/FixedFontSize)</param> /// <param name="popUpsize">Size of the popup</param> /// <param name="fontSizeQuestion">Font size for question text</param> /// <param name="fontSizeOptions">Font size for option text</param> /// <param name="margin">Padding around the text</param> /// <returns></returns> IEnumerator SetSize(QuizPopUpDataModel quizPopUpDataModel, SizeOption sizeOption) { contentRect.GetComponent <ContentSizeFitter>().enabled = false; contentRect.GetComponent <VerticalLayoutGroup>().padding = quizPopUpDataModel.popUpSetting.padding; resultPanel.GetComponent <VerticalLayoutGroup>().padding = quizPopUpDataModel.popUpSetting.padding; switch (sizeOption) { case SizeOption.FixedPopupSize: //font size will be reset according to the popup size SetContentSize(size); //Set popup size before setting text size questionText.enableAutoSizing = false; questionText.fontSize = quizPopUpDataModel.popUpSetting.question.size; questionText.GetComponent <LayoutElement>().minHeight = questionText.fontSize; float tmSize = 0; TextMeshProUGUI[] txtOptions = optionsRect.GetComponentsInChildren <TextMeshProUGUI>(); //1. Enable Auto Size of all text foreach (var tm in txtOptions) { tm.enableAutoSizing = true; } yield return(new WaitForEndOfFrame()); //2. Get total size of all text after AutoSize enabled foreach (var tm in txtOptions) { tmSize += tm.fontSize; } //3. Disable AutoSize of all text and set average size for all text foreach (var tm in txtOptions) { tm.enableAutoSizing = false; tm.fontSize = tmSize / txtOptions.Length; } break; case SizeOption.FixedContentSize: //font size will be fixed but popup size will be changed accordingly contentRect.GetComponent <ContentSizeFitter>().enabled = true; questionText.fontSize = quizPopUpDataModel.popUpSetting.question.size; foreach (var obj in contentRect.GetComponentsInChildren <Button>()) { obj.GetComponent <TextMeshProUGUI>().fontSize = quizPopUpDataModel.popUpSetting.options.size; } yield return(new WaitForEndOfFrame()); SetContentSize(contentRect.GetComponent <RectTransform>().sizeDelta); //Set popup size after calculating text size break; case SizeOption.FixedPercentage: //popup size will be based on Percentage var rect = transform.GetComponentInParent <Canvas>().GetComponent <RectTransform>().sizeDelta; float height = rect.y * ((float)quizPopUpDataModel.popUpSetting.percentage / 100.0f); float width = (rect.x / rect.y) * height - 100; //100 referes control panel width size = new Vector2(width, height); StartCoroutine(SetSize(quizPopUpDataModel, SizeOption.FixedPopupSize)); // call SetSize to fit text into new size of popup break; } yield return(new WaitForEndOfFrame()); PlacePopUp(rectTransform); var resultPanelRect = resultPanel.GetComponent <RectTransform>(); resultPanelRect.anchoredPosition = contentRect.anchoredPosition; resultPanelRect.sizeDelta = contentRect.sizeDelta; resultPanelRect.anchorMax = contentRect.anchorMax; resultPanelRect.anchorMin = contentRect.anchorMin; }
/// <summary> /// Converts this numeric value into a string that represents the number expressed as a size /// value in bytes, kilobytes, megabytes, gigabytes, terabyte, petabyte, exabyte, depending /// on the size. /// </summary> /// <param name="value"> /// The value to be converted. /// </param> /// <param name="binary"> /// true for the binary numeral system; otherwise, false for the decimal numeral system. /// </param> /// <param name="suffix"> /// true to show the size unit suffix; otherwise, false. /// </param> /// <param name="sizeOptions"> /// </param> public static string FormatSize(this long value, bool binary = true, bool suffix = true, SizeOption sizeOptions = SizeOption.None) { if (value == 0) { return(value.FormatSize(SizeUnit.Byte, binary, suffix, sizeOptions)); } var i = (int)Math.Floor(Math.Log(Math.Abs(value), binary ? 1024 : 1000)); return(value.FormatSize((SizeUnit)i, binary, suffix, sizeOptions)); }
public decimal CalculateProfit(SizeOption sizeOption, List <Tuple <decimal, decimal> > count) { return(sizeOption.Price - CalculateCost(count)); }
/// <summary> /// Converts this numeric value into a string that represents the number expressed as a size /// value in bytes, kilobytes, megabytes, gigabytes, terabyte, petabyte, exabyte, depending /// on the size. /// </summary> /// <param name="value"> /// The value to be converted. /// </param> /// <param name="binary"> /// true for the binary numeral system; otherwise, false for the decimal numeral system. /// </param> /// <param name="sizeOptions"> /// </param> public static string FormatSize(this long value, bool binary, SizeOption sizeOptions) => value.FormatSize(SizeUnit.Byte, binary, true, sizeOptions);
/// <summary> /// Converts this numeric value into a string that represents the number expressed as a size /// value in bytes, kilobytes, megabytes, gigabytes, terabyte, petabyte, exabyte, depending /// on the size. /// </summary> /// <param name="value"> /// The value to be converted. /// </param> /// <param name="sizeOptions"> /// </param> public static string FormatSize(this long value, SizeOption sizeOptions) => value.FormatSize(true, true, sizeOptions);
public void AddSize(SizeOption size) { Sizes.Add(size); }