Ejemplo n.º 1
0
        public ActionResult Create(int productId)
        {
            var vm = new ProductVersionViewModel {
                ProductId = productId
            };

            return(View(vm));
        }
Ejemplo n.º 2
0
 public void ViewModelToEntity_EntityIdNotPreset_ThrowsException()
 {
     var vm = new ProductVersionViewModel
     {
         Id    = 1,
         Major = "1",
         Minor = "1",
         Build = "1",
         Patch = "1"
     };
 }
Ejemplo n.º 3
0
        public ActionResult Create(ProductVersionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var version = new ProductVersion {
                    ProductId = vm.ProductId
                };
                converter.ViewmodelToEntity(vm, ref version);

                service.Add(version);

                return(RedirectToAction("Edit", "Product", new { id = version.ProductId }));
            }
            else
            {
                return(View(vm));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> UpdateProductVersion(ProductVersionViewModel input)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = await this.manager.UpdateProductVersion(input);

                    return(Json(new { success = $"Промените във версия '{entity.Name}' са запазени!" }));
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
            else
            {
                return(BadRequest(ModelState.GetErrorsList()));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Edit(ProductVersionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var version = service.GetById(vm.Id);
                if (version == null)
                {
                    return(new HttpNotFoundResult());
                }
                else
                {
                    converter.ViewmodelToEntity(vm, ref version);

                    service.Update(version);

                    return(RedirectToAction("Edit", "Product", new { id = version.Product.Id }));
                }
            }
            else
            {
                return(View(vm));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> AddProductVersion(ProductVersionViewModel input)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = await this.manager.CreateProductVersion(input);

                    TempData["success"] = "Версията е добавена";
                    return(RedirectToAction("Edit", new { id = input.ProductId }));
                }
                catch (Exception ex)
                {
                    TempData["error"] = ex.Message;
                    return(RedirectToAction("Edit", new { id = input.ProductId }));
                }
            }
            else
            {
                TempData["error"] = ModelState.GetErrorsList();
                return(RedirectToAction("Edit", new { id = input.ProductId }));
            }
        }