예제 #1
0
        public ActionResult Create(ProductTypeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var productType = _mapper.Map <ProductType>(model);
                // productType.ProductTypeId = 2;
                productType.CreatedAt = DateTime.Now;
                productType.UpdatedAt = DateTime.Now;

                var isSuccess = _repo.Create(productType);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }