Exemplo n.º 1
0
        public async Task <IActionResult> Edit(BrandDetailViewModel brandModel)
        {
            //TODO: make brand edit friendly error page
            if (!ModelState.IsValid)
            {
                this.TempData.AddFailureMessage(string.Format(FailureEditItemMessage, brandModel.Name));
                return(this.RedirectToAction(nameof(Index)));
                //return this.BadRequest();
            }

            await this.brandService.EditAsync(brandModel.Id, brandModel.Name);

            this.TempData.AddSuccessMessage(string.Format(SuccessEditItemMessage, brandModel.Name));
            return(this.RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit([FromRoute(Name = "id")] int brandId)
        {
            var brand = await this.brandService.GetByIdAsync(brandId);

            if (brand == null)
            {
                return(this.BadRequest());
            }

            var editBranch = new BrandDetailViewModel
            {
                Name = brand.Name,
            };

            return(this.View(editBranch));
        }
Exemplo n.º 3
0
        public async Task <ActionResultResponse <BrandDetailViewModel> > GetDetail(string tenantId, string id)
        {
            var brandInfo = await _brandRepository.GetInfo(tenantId, id);

            var brandViewModel = new BrandDetailViewModel()
            {
                Id               = brandInfo.Id,
                Name             = brandInfo.Name,
                IsActive         = brandInfo.IsActive,
                Description      = brandInfo.Description,
                Address          = brandInfo.Address,
                Email            = brandInfo.Email,
                PhoneNumber      = brandInfo.PhoneNumber,
                Website          = brandInfo.Website,
                Logo             = brandInfo.Logo,
                ConcurrencyStamp = brandInfo.ConcurrencyStamp
            };

            return(new ActionResultResponse <BrandDetailViewModel>
            {
                Code = 1,
                Data = brandViewModel
            });
        }