public async Task <IActionResult> ApproveOfSupplier([FromForm] NewSupplierRequest sp, [FromQuery] string messageId = "", [FromQuery] string returnUrl = null) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(sp.UserName); var success = await _streinger.AddSupplier(new Supplier() { Name = sp.Name, Company = sp.Company, Address = sp.Address, Geolocation = sp.Geolocation, Description = sp.Description }); if (success) { var supp = await _streinger.Suppliers(sp.Name, sp.Address); await AddSupplierToContext(user, supp.Id.ToString()); await _userManager.AddToRoleAsync(user, "supplier"); await _userManager.UpdateAsync(user); return(await RemoveMessage(messageId)); } } return(RedirectStandart("")); }
public async Task <ActionResult <SupplierDTO> > CreateSupplier(NewSupplierRequest newSupplierRequest) { Response <SupplierDTO> response = await this.suppliersManager.CreateSupplier(newSupplierRequest).ConfigureAwait(false); if (response.IsOperationSucceeded) { return(this.StatusCode(StatusCodes.Status201Created, response.DTOObject)); } return(this.StatusCode(StatusCodes.Status403Forbidden, response.SuccessOrFailureMessage)); }
public async Task <IActionResult> SupplierForm(NewSupplierRequest model, string returnUrl = null) { if (ModelState.IsValid) { var admins = await _userManager.GetUsersInRoleAsync("admin"); foreach (var admin in admins) { await _messenger.Send(new { Data = model, Type = "SupplierForm" }, admin, await _userManager.GetUserAsync(User)); } return(RedirectToAction("Index", "Search")); } return(View(model)); }
public Task <Response <SupplierDTO> > CreateSupplier(NewSupplierRequest newSupplierRequest) { throw new NotImplementedException(); }