public async Task <IActionResult> GetCompanyInviteUsers([FromBody] CompanyUsersRequest request) { JsonResponse <IEnumerable <CompanyInviteUsersList> > objResult = new JsonResponse <IEnumerable <CompanyInviteUsersList> >(); try { IEnumerable <CompanyInviteUsersList> companyInfo = await this._companyService.GetCompanyInviteUsers(request); if (companyInfo != null && companyInfo.Count() > 0) { objResult.Data = companyInfo; objResult.Status = StaticResource.SuccessStatusCode; objResult.Message = StaticResource.SuccessMessage; return(new OkObjectResult(objResult)); } else { objResult.Data = null; objResult.Status = StaticResource.NotFoundStatusCode; objResult.Message = StaticResource.NotFoundMessage; return(new OkObjectResult(objResult)); } } catch (Exception ex) { HttpContext.RiseError(ex); objResult.Data = null; objResult.Status = StaticResource.FailStatusCode; objResult.Message = StaticResource.FailMessage; } return(new OkObjectResult(objResult)); }
public async Task <int> InviteIndividualUser(CompanyUsersRequest usersRequest, Guid guid) { try { int status = 0; DynamicParameters ObjParm = new DynamicParameters(); ObjParm.Add("@FirstName", usersRequest.FirstName); ObjParm.Add("@LastName", usersRequest.LastName); ObjParm.Add("@CompanyId", usersRequest.CompanyId); ObjParm.Add("@EmailAddress", usersRequest.Email); ObjParm.Add("@ActivationToken", guid); ObjParm.Add("@EmailSender", config.GetValue <string>("AuthMessageSenderOptions:SendGridEmail")); ObjParm.Add("@EmailSubject", config.GetValue <string>("AuthMessageSenderOptions:WelcomeEmail")); ObjParm.Add("@ReturnStatus", dbType: DbType.Int32, direction: ParameterDirection.Output); using (IDbConnection con = new SqlConnection(_connectionString)) { await con.QueryAsync("dbo.SSP_addIndividualInviteUser", ObjParm, commandType : CommandType.StoredProcedure); status = ObjParm.Get <int>("@ReturnStatus"); } return(status); } catch (Exception ex) { throw ex; } }
public async Task <int> InviteIndividualUser(CompanyUsersRequest usersRequest, HttpContext context) { try { int returnResult = 0; bool emailExist = await this.authRepo.EmailExist(usersRequest.Email); if (emailExist) { returnResult = 2; return(returnResult); // Email Exist } else { Guid guid = Guid.NewGuid(); InviteUsersList inviteUser = new InviteUsersList(); inviteUser.EmailAddress = usersRequest.Email; inviteUser.ActivationToken = guid; InviteEmailData response = await this.commonEmailsService.SendUserInviteEmails(inviteUser, context); if (response.InviteStatus == 1) { returnResult = await this._companyRepo.InviteIndividualUser(usersRequest, guid); } } return(returnResult); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> InviteIndividualUser([FromBody] CompanyUsersRequest request) { JsonResponse <User> objResult = new JsonResponse <User>(); if (request != null) { try { HttpContext context = HttpContext; int info = await this._companyService.InviteIndividualUser(request, context); switch (info) { case 0: objResult.Data = null; objResult.Status = StaticResource.NotFoundStatusCode; objResult.Message = StaticResource.SomethingWentWrong; break; case 1: objResult.Data = null; objResult.Status = StaticResource.SuccessStatusCode; objResult.Message = StaticResource.ActivationLinkSent; break; case 2: objResult.Data = null; objResult.Status = StaticResource.DuplicateStatusCode; objResult.Message = StaticResource.EmailExist; break; default: objResult.Data = null; objResult.Status = StaticResource.NotFoundStatusCode; objResult.Message = StaticResource.SomethingWentWrong; break; } } catch (Exception ex) { HttpContext.RiseError(ex); objResult.Data = null; objResult.Status = StaticResource.FailStatusCode; objResult.Message = StaticResource.FailMessage; } } else { objResult.Data = null; objResult.Status = StaticResource.FailStatusCode; objResult.Message = StaticResource.InvalidMessage; } return(new OkObjectResult(objResult)); }
public async Task <IEnumerable <CompanyMembers> > GetCompanyUsers(CompanyUsersRequest usersRequest) { try { return(await this._companyRepo.GetCompanyUsers(usersRequest)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <CompanyMembers> > GetCompanyUsers(CompanyUsersRequest usersRequest) { try { IEnumerable <CompanyMembers> userCompany = null; using (IDbConnection con = new SqlConnection(_connectionString)) { userCompany = await con.QueryAsync <CompanyMembers>("dbo.SSP_getCompanyUsersList", new { CompanyId = usersRequest.CompanyId, FirstName = usersRequest.FirstName, LastName = usersRequest.LastName, Email = usersRequest.Email, OffSet = usersRequest.OffSet, Limit = usersRequest.Limit, }, commandType : CommandType.StoredProcedure); } return(userCompany); } catch (Exception ex) { throw ex; } }