private Provider CreateNewProvider() { var provider = new Provider(); _providerRepository.Add(provider); return(provider); }
public Provider Add(Provider provider) { var _provider = _providerRepository.Add(provider); _unitOfWork.Commit(); if (!string.IsNullOrEmpty(provider.Tags)) { string[] tags = provider.Tags.Split(','); for (var i = 0; i < tags.Length; i++) { var tagId = StringHelper.ToUnsignString(tags[i]); if (_tagRepository.Count(x => x.ID == tagId) == 0) { Tag tag = new Tag(); tag.ID = tagId; tag.Name = tags[i]; tag.Type = CommonConstants.ProviderTag; _tagRepository.Add(tag); } ProviderTag providerTag = new ProviderTag(); providerTag.ProviderID = provider.ID; providerTag.TagID = tagId; _providerTagRepository.Add(providerTag); } } return(_provider); }
public async Task <Provider> Add(Provider provider) { var dulicateEmail = (await _repository.Get(x => x.Email.Trim().Equals(provider.Email.Trim()))).Any(); if (dulicateEmail) { _notification.Add("Email already used"); return(null); } using var transaction = await _repository.BeginTransaction(); await _repository.Add(provider); await SendWelcomeEmail(provider); if (provider.Documents.Any()) { await UploadDocuments(provider); } await transaction.CommitAsync(); return(provider); }
public async Task <IActionResult> Create(ProviderViewModel providerViewModel) { if (ModelState.IsValid) { providerViewModel.Id = Guid.NewGuid(); await providerRepository.Add(mapper.Map <Provider>(providerViewModel)); return(RedirectToAction(nameof(Index))); } return(View(providerViewModel)); }
public async Task <IActionResult> Create(ProviderViewModel providerViewModel) { if (!ModelState.IsValid) { return(View(providerViewModel)); } await _providerRepository.Add(_mapper.Map <Provider>(providerViewModel)); return(RedirectToAction(nameof(Index))); }
public async Task Add(Provider provider) { if (!ExecuteValidation(new ProviderValidation(), provider) || !ExecuteValidation(new AddressValidation(), provider.Address)) { return; } if (_providerRepository.Search(s => s.Document == provider.Document).Result.Any()) { Notify("There is already a provider with this information document."); return; } await _providerRepository.Add(provider); }
public async Task <bool> Add(Provider provider) { if (!ExecuteValidation(new ProviderValidation(), provider) || !ExecuteValidation(new AddressValidation(), provider.Address)) { return(false); } if (_providerRepository.Search(x => x.Document == provider.Document).Result.Any()) { Notify("There is already a supplier with the document informed."); return(false); } await _providerRepository.Add(provider); return(true); }
public async Task <IActionResult> Create([FromBody] ProviderDto provider) { var result = await providerRepository.Find(x => x.Nit == provider.Nit); if (result != null) { return(BadRequest("El proveedor ya existe.")); } var newProvider = mapper.Map <Provider>(provider); newProvider.Id = Guid.NewGuid(); newProvider.FechaCreacion = DateTime.Now; newProvider.FechaModificacion = DateTime.Now; await providerRepository.Add(newProvider); return(Created(Url.Link("GetProvider", new { id = newProvider.Id }), newProvider)); }
public async Task <bool> Add(Provider provider) { if (!ExecuteValidation(new ProviderValidation(), provider) && !ExecuteValidation(new AddressValidation(), provider.Address)) { return(false); } var providerDocument = await _providerRepository.Get(p => p.Document == provider.Document); if (providerDocument.Any()) { Notify($"Já existe o documento {provider.Document} cadastrado."); return(false); } await _providerRepository.Add(provider); return(true); }
public ActionResult AddProvider(ProviderViewModel model) { if (ModelState.IsValid) { model.totalClicks = 0; model.uniqueClicks = 0; model.dateAdded = DateTime.Now; var provider = _mapper.Map <Provider>(model); _providerRepository.Add(provider); if (_providerRepository.Save()) { TempData["Message"] = $"{model.name} Successfully added loan provider list"; TempData["MessageState"] = "text-success"; return(RedirectToAction("AddProvider")); } TempData["Message"] = "Something went wrong unable to add provider"; TempData["MessageState"] = "text-danger"; return(View()); } return(View()); }
public void Add(Provider provider) { _providerRepository.Add(provider); }
public long Add(Provider provider) { return(_providerRepository.Add(provider)); }
public Provider Add(Provider Provider) { return(_providerRepository.Add(Provider)); }
public async Task Create(Provider provider) { _providerRepository.Add(provider); await _providerRepository.UnitOfWork.SaveChangesAsync().ConfigureAwait(false); }