Beispiel #1
0
        public async Task <ActionResult> Create(CategoryRequest categoryRequest)
        {
            if (categoryRequest.Name != null)
            {
                var Token = HttpContext.Session.GetString("Token");
                if (_userClient.CheckToken(Token, User.Identity.Name) == null)
                {
                    return(Redirect("/Administration/Home/Login"));
                }
                else
                {
                    if (Token == null)
                    {
                        Token = await _userClient.CheckToken(Token, User.Identity.Name);
                    }
                }
                var result = await _categoryApi.Create(Token, categoryRequest);

                if (result > 0)
                {
                    return(Redirect("Index"));
                }
            }
            return(View());
        }
        public async Task <IActionResult> Create(CategoryCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }
            request.LanguageId = GetLanguageId();
            var result = await _categoryApiCilent.Create(request);

            if (result.IsSuccessed)
            {
                TempData["Result"] = "Tạo mới thành công";
                return(RedirectToAction("Index", "Category"));
            }
            ModelState.AddModelError("", result.Message);
            return(View(request));
        }
        public async Task <IActionResult> Create(CategoryCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var result = await _categoryApiClient.Create(request);

            if (result == 1)
            {
                TempData["result"] = "Thêm mới danh mục thành công";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Thêm danh mục thất bại");
            return(View(request));
        }