示例#1
0
        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 }));
        }
示例#2
0
        private static void AddButtonClick(object o, EventArgs e)
        {
            var view       = new AddFormView();
            var model      = new AddFormModel();
            var controller = new AddFormController(model, view);

            view.ShowDialog();
        }
示例#3
0
 public ActionResult AddParameter(AddFormModel form)
 {
     return(View(new AddFormModel
     {
         Parameters = Get <IParameterRepository>().GetAllParam(),
         CheckBoxesParents = new List <bool>(),
         CheckBoxesChildren = new List <bool>()
     }));
 }
示例#4
0
        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());
        }
示例#5
0
        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));
        }
示例#6
0
        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("Форма с входными данными не прошла валидацию.");
            }
        }
示例#7
0
 public AddFormPresenter(Assigment1.AddForm addForm)
 {
     this.addFormView = addForm;
     viewManagerModel = new AddFormModel(this);
 }