public async Task <ActionResult> Create(CreateProviderModel provider) { var apiRep = new APIResponse(); apiRep.Error = false; apiRep.Data = await _providerService.Create(provider); return(Ok(apiRep)); }
private async Task ProviderCreate() { for (int i = 1; i <= 10; i++) { await _providerService.Create($"SomeProviderName{i}"); } }
public async Task <IActionResult> Create(string name) { if (Request.Headers["Role"] != "Admin") { return(BadRequest()); } await _providerService.Create(name); return(Ok()); }
public ActionResult <Provider> Create([FromForm] Provider provider) { var curProvider = _providerService.GetProviderByName(provider.Name); if (curProvider != null) { return(BadRequest(new { message = "Provider has been used" })); } _providerService.Create(provider); return(CreatedAtRoute("GetProvider", new { id = provider.Id.ToString() }, provider)); }
private async Task addProvider() { IsBusy = true; var service = new ProviderService(_configuration); var response = await service.Create(new Models.Shared.ViewModels.ProviderViewModel { Name = this.Name }); if (response != null) { this._providersSource.AddOrUpdate(response); } IsBusy = false; }
public ActionResult Post([FromBody] ProviderDTO value) { TryValidateModel(value); try { var provider = mapper.Map <Provider>(value); service.Create(provider); value.Id = provider.Id; return(Ok(new { Success = true, Message = "", data = value })); } catch (Exception ex) { logger.LogCritical(ex.StackTrace); return(Ok(new { Success = false, Message = "The name is already in use" })); } }