public async Task <IActionResult> CreateDemandAsync([FromBody] DemandDto demandDto) { try { var currentUser = await userManager.GetUserAsync(HttpContext.User); var userAccountId = GetUserAccountId(); var roles = await userManager.GetRolesAsync(currentUser); demandDto.CreatedUser = currentUser.FirstName + " " + currentUser.LastName; demandDto.ModifiedUser = currentUser.FirstName + " " + currentUser.LastName; demandDto.CreateDate = DateTime.Now; demandDto.ModifyDate = DateTime.Now; demandDto.CompanyUserAccountId = userAccountId; if (roles.Contains("Company Admin") || roles.Contains("Company User")) { var companyId = companyUserService.GetCompanyUserbyUserAccountId(userAccountId).CompanyId; demandDto.CompanyId = companyId; } var result = demandService.Create(demandDto); return(Ok()); } catch (Exception) { throw; } }
public async Task <IActionResult> Create([FromBody] DemandRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _demandService.Create(request); if (!result.IsSuccessed) { return(BadRequest(result.Message)); } return(Ok()); }