public long Add(Vendor obj) { if (IsDuplicate(obj.VendorCode, obj.Id, obj.CustomerId) == false) { return(_vendorRepository.Add(obj)); } else { Expression <Func <Vendor, bool> > res = x => x.VendorCode == obj.VendorCode && x.CustomerId == obj.CustomerId && x.IsActive == false; var model = _vendorRepository.Get(res); if (model != null) { obj.Id = model.Id; obj.IsActive = true; _vendorRepository.Detach(model); _vendorRepository.Update(obj); return(obj.Id); } else { return(0); } } }
public IActionResult Add(EntityViewModel vm) { var userID = User.FindFirstValue(ClaimTypes.NameIdentifier); if (vm.EntityOfInterest.Name != null) { ValidateVendor(vm, userID); if (ModelState.IsValid) { //Convert VMVendor to DBVendor Vendor vendor = new Vendor { UserID = userID, Name = vm.EntityOfInterest.Name, IsDisplayed = vm.EntityOfInterest.IsDisplayed, IsDefault = false //User's cannot create default vendors. }; //Add vendor to the DB _vendorRepository.Add(vendor); TempData["Message"] = "Vendor successfully added."; return(RedirectToAction("Index")); } } return(View(vm)); }
public async Task <IActionResult> Add(Vendor vendor) { if (ModelState.IsValid) { vendorRepo.Add(vendor); await vendorRepo.Save(); return(RedirectToAction(nameof(Index))); } return(View(vendor)); }
public override async Task <ActionResult> HandleAsync([FromBody] CreateVendorRequest request, CancellationToken cancellationToken = default) { var Vendor = new Vendor { Name = request.Name }; await _repo.Add(Vendor); await _repo.Save(); return(Ok(Vendor)); }
public int CreateVendor(Vendor vendor, ref Error error) { _validateVendorForm(vendor, ref error); if (error.ErrorCode != ErrorCode.OKAY) { return(-1); } vendor.Active = true; return(_vendorRepository.Add(vendor.MapToEntity())); }
public async Task <bool> Handle(CreateVendorCommand command, CancellationToken cancellationToken) { _vendorRepository.UnitOfWork.BeginTransaction(); try { _vendorRepository.Add(command.VendorMaster); _vendorRepository.UnitOfWork.CommitTransaction(); }catch (Exception ex) { _vendorRepository.UnitOfWork.RollbackTransaction(); } return(await _vendorRepository.UnitOfWork.SaveChangesAsync()); }
public async Task <VendorDto> Create(Guid userId, VendorForCreationDto vendorForCreationDto) { var vendor = new Vendor() { Name = vendorForCreationDto.Name, CUIL = vendorForCreationDto.CUIL, Phone = vendorForCreationDto.Phone, Mail = vendorForCreationDto.Mail, //Active = vendorForCreationDto.Active, Description = vendorForCreationDto.Description, CreatedBy = userId }; vendor = await _vendorRepository.Add(vendor); await _vendorRepository.CommitAsync(); return(_mapper.Map <Vendor, VendorDto>(vendor)); }
public async Task <IActionResult> Create([FromBody][Required] VendorDm vendor) { try { var isCreated = await _vendorRepository.Add(vendor); if (isCreated) { return(Ok(vendor)); } else { return(Ok("Some error occurred.")); } } catch (ArgumentException) { return(Conflict("Vendor Already Present.")); } }
private Vendor GetOrAddVendor(XmlNode node) { var vendorNumber = StringToInt(ParseNode(node, "Vendor_No_")); var existingVendor = _vendorRepo.GetByVendorNumber(vendorNumber); if (existingVendor != null) { return(existingVendor); } else { Vendor newVendor = new Vendor { VendorName = ParseNode(node, "Vendor_Name"), VendorNumber = vendorNumber, Status = VendorStatus.NeedsReview, VendorStatusChangeDate = DateTime.Now }; _vendorRepo.Add(newVendor); return(newVendor); } }
public async Task <VendorResponse> AddVendorAsync(AddVendorRequest request) { var vendorItem = _vendorMapper.Map(request); var newUser = new Entities.AppUser { UserName = request.ContactEmail, Email = request.ContactEmail }; bool isCreated = await _userRepository.SignUpAsync(newUser, "partyAgile21", "Vendor"); if (isCreated) { vendorItem.UserId = newUser.Id; } var result = _vendorRepository.Add(vendorItem); await _vendorRepository.UnitOfWork.SaveChangesAsync(); var vendorEvent = new VendorEvent { Vendor = result, VendorId = result.Id, EventId = request.EventId, Budget = new Price { Amount = request.Budget.Amount, Currency = request.Budget.Currency }, DepositPaid = new Price { Amount = request.DepositPaid.Amount, Currency = request.Budget.Currency } }; _vendorEventRepository.Add(vendorEvent); await _vendorEventRepository.UnitOfWork.SaveChangesAsync(); return(_vendorMapper.Map(result)); }
public void Create(VendorDto vendor) { repository.Add(vendor); }
public void Addvendor(Vendor vendor) { vendor.isDelete = false; _vendorRepository.Add(vendor); _unitOfWork.Commit(); }
public void CreateVendor(VendorDto vendorDto) { vendorRepository.Add(vendorDto.MappingVendor()); }
public async Task <IActionResult> Post([FromBody] Models.Vendor vendor) { var id = await _vendorRepository.Add(vendor); return(Ok(id)); }
public async Task AddToDb(Vendor vendor) { await _vendorRepository.Add(vendor); }