Exemplo n.º 1
0
        public ResponseMessage CreateVendor(AddVendor vendor)
        {
            ResponseMessage responseMessage = new ResponseMessage();

            responseMessage = _vendorRepository.CreateVendor(vendor);
            return(responseMessage);
        }
Exemplo n.º 2
0
        public IActionResult Post([FromBody] VendorDto vendorDto)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var vendor = Mapper.Map <Vendor>(vendorDto);
                if (_vendorRepository.VendorExists(vendor))
                {
                    return(StatusCode(500, "Vendor already exists."));
                }

                var userId        = User.FindFirstValue(ClaimTypes.NameIdentifier);
                var profile       = _accountRepository.GetUserProfile(userId);
                var createdVendor = _vendorRepository.CreateVendor(vendor, profile.UserProfileId);

                if (createdVendor == null)
                {
                    return(StatusCode(500, "A problem happened while handling your request."));
                }

                var createdVendorToReturn = Mapper.Map <VendorDto>(createdVendor);
                return(Created(createdVendorToReturn));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed in Post /Vendors: {ex}");
                return(StatusCode(500, "A problem happened while handling your request."));
            }
        }
Exemplo n.º 3
0
 public IActionResult CreateVendor(Vendor vendor)
 {
     if (ModelState.IsValid)
     {
         if (_ctx.VendorNameExists(vendor.VendorName))
         {
             ViewBag.vendorExist = "Vendor name is already existed!";
             return(View("CreateVendor", vendor));
         }
         vendor.Status = true;
         _ctx.CreateVendor(vendor);
         return(RedirectToAction(nameof(ListAllVendor)));
     }
     return(View(vendor));
 }
        public async Task ShouldCreateVendorFromVendorDomainObj()
        {
            var vendorDomainObj = new VendorDomainObj
            {
                AccountNumber   = "TESTVEN0001",
                Name            = "Test Vendor",
                CreditRating    = CreditRating.Superior,
                PreferredVendor = true,
                IsActive        = true
            };

            await _vendorRepo.CreateVendor(vendorDomainObj);

            var vendor = await _vendorRepo.GetVendorByID(vendorDomainObj.BusinessEntityID);

            Assert.NotNull(vendor);
            Assert.Equal("TESTVEN0001", vendor.AccountNumber);
        }
Exemplo n.º 5
0
 public int CreateVendor(VendorModel vendorModel)
 {
     try
     {
         Vendor vendor = null;
         vendor = _vendorRepository.CreateVendor(new Vendor()
         {
             Name          = vendorModel.Name,
             Address       = vendorModel.Address,
             Email         = vendorModel.Email,
             ContactNumber = vendorModel.ContactNumber,
             ContactPerson = vendorModel.ContactPerson,
             CreatedBy     = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID
         });
         return(vendor.ID);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 public int CreateVendor(Vendor vendor)
 {
     return(vendorRepository.CreateVendor(vendor));
 }