public JsonResult AddOrUpdateProduct(AddFormModel product) { var imageNames = new List <string>(); foreach (var productImage in product.Images) { var path = Server.MapPath("~/TempFolder/" + productImage); var originalImage = Image.FromFile(path); var thumbImage = ScaleImage(originalImage, 100, 100); var image = ScaleImage(originalImage, 601, 352); var newName = $"{product.Articul}_{Guid.NewGuid()}.jpg"; imageNames.Add(newName); image.Save(Server.MapPath("~/ProductImages/" + newName)); thumbImage.Save(Server.MapPath("~/ProductImages/Thumb/" + newName)); } var id = _productRepository.AddProduct(new ProductCard { Name = product.Name, Articul = product.Articul, Description = product.Description, ImageNames = imageNames, Type = product.Type, Material = product.Material, Prices = product.Sizes.Select(x => new SizePrice { SizeId = x.SizeId, Price = x.Price }) .ToList(), }); return(Json(new { Id = id })); }
private static void AddButtonClick(object o, EventArgs e) { var view = new AddFormView(); var model = new AddFormModel(); var controller = new AddFormController(model, view); view.ShowDialog(); }
public ActionResult AddParameter(AddFormModel form) { return(View(new AddFormModel { Parameters = Get <IParameterRepository>().GetAllParam(), CheckBoxesParents = new List <bool>(), CheckBoxesChildren = new List <bool>() })); }
public IActionResult Add(AddFormModel formModel) { var birthday = new Birthday(formModel.BirthdayDateTime); var person = new Person(Guid.NewGuid().ToString(), formModel.Name, birthday); Repository.Insert(person, out bool addWasSuccessful); if (addWasSuccessful) { return(RedirectToAction("Index")); } return(BadRequest()); }
public ActionResult GetPriceArea() { var sizes = _productRepository.GetSizes(); var model = new AddFormModel { SizePriceModels = sizes.Select(x => new SizePriceModel { Price = x.Price, SizeId = x.SizeId, SizeName = x.SizeName }).ToList() }; return(PartialView("PriceAria", model)); }
public ActionResult AddingParameter(AddFormModel form) { ParametersViewModel viewModel = new ParametersViewModel(); if (ModelState.IsValid) { if (form != null) { viewModel.AddForm = form; viewModel.AddForm.Parameters = Get <IParameterRepository>().GetAllParam(); viewModel.SetPropertiesAndMetadata(); if (!form.parameter.MetaData.Is_var) { var flag = Get <IParameterRepository>().Add(form.parameter); return(RedirectTo <ParametersController>(a => a.AddConfirm())); } else { if (form.NumValue == 0) { return(RedirectTo <ParametersController>(a => a.AddParameter(form))); } else { TempData["newParameter"] = form.parameter; var varForm = new VarFormModel() { NumVariant = form.NumValue, Variants = new Variant[form.NumValue], Parameter = form.parameter }; return(RedirectTo <ParametersController>(a => a.Var(varForm))); } } } else { throw new Exception("Отсутствует форма с данными,необходимы для создания параметра здоровья."); } } else { throw new Exception("Форма с входными данными не прошла валидацию."); } }
public AddFormPresenter(Assigment1.AddForm addForm) { this.addFormView = addForm; viewManagerModel = new AddFormModel(this); }