예제 #1
0
        public async Task <ActionResult <VendorForGetDTO> > Put(int id, VendorForEditDTO model)
        {
            if (id != model.Id)
            {
                return(BadRequest(new ApiResponse(400, StringConcatenates.NotEqualIds(id, model.Id))));
            }

            if (!await _vendorRepository.IsExist(id).ConfigureAwait(true))
            {
                return(NotFound(new ApiResponse(404, StringConcatenates.NotExist("Vendor", id))));
            }

            if (await _vendorRepository.IsExist(model.Id, model.Name, model.CategoryId).ConfigureAwait(true))
            {
                return(Conflict(new ApiResponse(409, StringConsts.EXISTED)));
            }

            Vendor oldVendor = await _vendorRepository.GetAsync(id).ConfigureAwait(true);

            Vendor vendor = _mapper.Map <Vendor>(model);

            vendor.LicenseName    = oldVendor.LicenseName;
            vendor.LogoName       = oldVendor.LogoName;
            vendor.PersonalIdName = oldVendor.PersonalIdName;

            _vendorRepository.Edit(vendor);
            await _unitOfWork.CompleteAsync().ConfigureAwait(true);

            VendorForGetDTO vendorDto = _mapper.Map <VendorForGetDTO>(vendor);

            return(Ok(vendorDto));
        }
예제 #2
0
        public async Task <IActionResult> Edit(Vendor vendor)
        {
            vendorRepo.Edit(vendor);
            await vendorRepo.Save();

            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
        public async Task EditAsync(VendorEditModel model)
        {
            var vendor = await _vendorRepository.GetAsync(model.Id);

            VendorFactory.Create(model, vendor, _userId);

            _vendorRepository.Edit(vendor);

            await _unitOfWork.SaveChangesAsync();
        }
예제 #4
0
        public async Task <ActionResult <VendorRejectForGetDTO> > Post(VendorRejectForAddDTO model)
        {
            if (!await _vendorRepository.IsExist(model.VendorId).ConfigureAwait(true))
            {
                return(NotFound(new ApiResponse(404, StringConcatenates.NotExist("Vendor", model.VendorId))));
            }

            VendorReject vendorReject = _mapper.Map <VendorReject>(model);

            await _vendorRejectRepository.AddAsync(vendorReject).ConfigureAwait(true);

            Vendor vendor = await _vendorRepository.GetAsync(model.VendorId).ConfigureAwait(true);

            vendor.Status = VendorStatusEnum.Rejected;
            _vendorRepository.Edit(vendor);

            await _unitOfWork.CompleteAsync().ConfigureAwait(true);



            VendorRejectForGetDTO vendorRejectDto = _mapper.Map <VendorRejectForGetDTO>(vendorReject);

            return(Ok(vendorRejectDto));
        }