Esempio n. 1
0
        public ActionResult Create(CreateCustomerCodeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var customerCode = _mapper.Map <CustomerCode1>(model);
                customerCode.CustomerCodeId = 1;
                customerCode.CreatedAt      = DateTime.Now;
                customerCode.UpdatedAt      = DateTime.Now;

                var isSuccess = _repo.Create(customerCode);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        public ActionResult Create(CreateCustomerCodeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var customerCode = _mapper.Map <CustomerCode1>(model);
                // customerCode.CustomerCodeId = 1;
                customerCode.CreatedAt = DateTime.Now;
                customerCode.UpdatedAt = DateTime.Now;
                //customerCode.ProductId = model.ProductId

                var isSuccess = _repo.Create(customerCode);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong");
                    return(View(model));
                }
                var Id = model.ProductId;
                // return RedirectToAction(nameof(Index));
                return(RedirectToAction("Create", "ErrorMessage", new { ProductId = Id }));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }