示例#1
0
        public async Task <ActionResult> Create(AddBrandViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var addBrandRequest = new AddBrandRequest {
                    Name = request.Name, Description = request.Description
                };
                var result = await _brandService.Create(addBrandRequest);

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
                Alert($"Brand Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
示例#2
0
        public async Task <IActionResult> Create(CreateBrandViewModel model)
        {
            var returnErrorModel = model;

            if (ModelState.IsValid)
            {
                model.CreatedById = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                var result = await _brandService.Create(model);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, result.ErrorMessage);
            }
            var subCategoryList = await _subCategoryService.GetAll();

            ViewBag.subCategoryDDL = subCategoryList.Result.Select(x => new SelectListItem
            {
                Selected = false,
                Text     = x.CategoryName,
                Value    = x.Id.ToString()
            }).ToList();
            return(View(returnErrorModel));
        }
示例#3
0
        public ActionResult Create(BrandViewModel model, string returnUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var modelMap = Mapper.Map <BrandViewModel, Brand>(model);
                _brandService.Create(modelMap);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.Brand)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    return(RedirectToAction("Index"));
                }

                return(Redirect(returnUrl));
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Brand.Create: ", ex.Message));

                return(View(model));
            }
        }
示例#4
0
        public ActionResult <Brand> PostBrand(BrandCreateRequest entity)
        {
            bool success = _brandSer.Create(entity);

            if (success)
            {
                return(Ok(entity));
            }
            return(Problem("Create failed!"));
        }
示例#5
0
        public async Task <IActionResult> Create([FromBody] BrandCreateRequest request)
        {
            var result = await _brandService.Create(request);

            if (!result.IsSuccess)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public IActionResult BrandCreate(BrandModel brand)
        {
            var entity = new Brand()
            {
                Name = brand.Name,
            };

            _brandService.Create(entity);
            return(Redirect("/admin/BrandList"));
        }
示例#7
0
        public async Task <IActionResult> Create(BrandCreateRequest request) //phuog
        {
            var brandId = await _brandService.Create(request);

            if (brandId == 0)
            {
                return(BadRequest()); //400
            }
            return(Ok());
            //return Created(nameof(GetById), productId);
        }
        public async Task <IActionResult> Post([FromBody] BrandForm model)
        {
            var brand = new Brand
            {
                Name        = model.Name,
                Slug        = model.Slug,
                IsPublished = model.IsPublished
            };

            await _brandService.Create(brand);

            return(CreatedAtAction(nameof(Get), new { id = brand.Id }, null));
        }
示例#9
0
        public IActionResult Incluir(Data.Models.Brand brand)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Providers = _providerService.GetSelectList();
                return(View(brand));
            }

            var result = _brandService.Create(brand);

            TempData.Put("Notification", result);
            return(RedirectToAction("Principal"));
        }
示例#10
0
        public async Task <Result> Post([FromBody] BrandParam model)
        {
            var brand = new Brand
            {
                Name        = model.Name,
                Slug        = model.Slug,
                Description = model.Description,
                IsPublished = model.IsPublished
            };
            await _brandService.Create(brand);

            return(Result.Ok());
        }
示例#11
0
        public async Task <IActionResult> Create(BrandViewsModels brand)
        {
            if (ModelState.IsValid)
            {
                var addBrand = await _brandService.Create(brand);

                if (addBrand != null)
                {
                    TempData["AddSuccessfuly"] = _localizer.GetLocalizedString("msg_AddSuccessfuly").ToString();
                    return(RedirectToAction("Index", addBrand));
                }
            }
            ViewData["AddFailure"] = _brandLocalizer.GetLocalizedString("err_AddFailure");
            return(View());
        }
示例#12
0
        public IActionResult Post([FromBody] BrandForm model)
        {
            if (ModelState.IsValid)
            {
                var brand = new Brand
                {
                    Name        = model.Name,
                    SeoTitle    = model.Name.ToUrlFriendly(),
                    IsPublished = model.IsPublished
                };

                _brandService.Create(brand);

                return(Ok());
            }
            return(new BadRequestObjectResult(ModelState));
        }
示例#13
0
        public async Task <IActionResult> Post([FromBody] BrandForm model)
        {
            if (ModelState.IsValid)
            {
                var brand = new Brand
                {
                    Name        = model.Name,
                    SeoTitle    = model.Slug,
                    IsPublished = model.IsPublished
                };

                await _brandService.Create(brand);

                return(CreatedAtAction(nameof(Get), new { id = brand.Id }, null));
            }
            return(BadRequest(ModelState));
        }
示例#14
0
        public IActionResult Create([FromBody] BrandViewModel model)
        {
            if (ModelState.IsValid)
            {
                var brand = new Brand
                {
                    Name        = model.Name,
                    SeoTitle    = StringHelper.ToUrlFriendly(model.Name),
                    IsPublished = model.IsPublished
                };

                brandService.Create(brand);

                return(Ok());
            }
            return(new BadRequestObjectResult(ModelState));
        }
        public async Task <IActionResult> CreateBrand(CreateBrand model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("~/Views/Admin/Brand/CreateBrand.cshtml", model));
                }
                var newBrand = await _brandService.Create(model);

                return(RedirectToAction("EditBrand", new { id = newBrand.Id }));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e.InnerException);
            }
        }
示例#16
0
        public ActionResult Create(BrandVIewModels model)
        {
            var brand = new Brand()
            {
                Id         = Guid.NewGuid(),
                Name       = model.Name,
                Logo       = model.Logo,
                CreateDate = DateTime.Now,
                CreateBy   = User.Identity.GetUserName(),
                ModifyDate = DateTime.Now,
                Status     = true,
            };
            var result = _brandService.Create(brand);

            if (result == true)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public async Task <ActionResult <BrandDetail_BrandDTO> > Create([FromBody] BrandDetail_BrandDTO BrandDetail_BrandDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Brand Brand = ConvertDTOToEntity(BrandDetail_BrandDTO);

            Brand = await BrandService.Create(Brand);

            BrandDetail_BrandDTO = new BrandDetail_BrandDTO(Brand);
            if (Brand.IsValidated)
            {
                return(BrandDetail_BrandDTO);
            }
            else
            {
                return(BadRequest(BrandDetail_BrandDTO));
            }
        }
示例#18
0
 public ActionResult Post([FromBody] BrandDto brand)
 {
     _brandService.Create(brand);
     return(NoContent());
 }