public HttpResponseMessage GetAccount(int accountID) { AccountInfo objAccountInfo = new AccountInfo(); TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; objAccountInfo.IsAuthenicated = true; accountsBusinessService = new AccountsBusinessService(accountsDataService); taccount account = accountsBusinessService.GetAccount(accountID, out transaction); objAccountInfo.Account = account; objAccountInfo.IsAuthenicated = true; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ReturnMessage = transaction.ReturnMessage; if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <AccountInfo>(HttpStatusCode.OK, objAccountInfo); return(response); } var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); }
public HttpResponseMessage GetUser() { Guid userID = new Guid(User.Identity.Name); AccountsApiModel accountsWebApiModel = new AccountsApiModel(); TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; accountsWebApiModel.IsAuthenicated = true; accountsBusinessService = new AccountsBusinessService(accountsDataService); User user = accountsBusinessService.GetUser(userID, out transaction); transaction.ReturnStatus = true; if (transaction.ReturnStatus == false) { accountsWebApiModel.ReturnMessage = transaction.ReturnMessage; accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel); return(badResponse); } accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.User = user; var response = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel); return(response); }
public HttpResponseMessage CreateAccountLineItem(HttpRequestMessage request, [FromBody] AccountInfo objAccountInfo) { TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; objAccountInfo.IsAuthenicated = true; accountsBusinessService = new AccountsBusinessService(accountsDataService); taccount account = accountsBusinessService.CreateAccountDetailLineItem( objAccountInfo.AccountID, objAccountInfo.AccountID, out transaction); if (transaction.ReturnStatus == false) { objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); } List <taccount> accounts = accountsBusinessService.GetAccountDetails(objAccountInfo.AccountID, out transaction); if (transaction.ReturnStatus == false) { objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); } taccount acc = accountsBusinessService.GetAccount(objAccountInfo.AccountID, out transaction); if (transaction.ReturnStatus == false) { objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); } transaction.ReturnMessage.Add("Detail line item succcessfully added."); objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.Accounts = accounts; objAccountInfo.Account = acc; var response = Request.CreateResponse <AccountInfo>(HttpStatusCode.OK, objAccountInfo); return(response); }
public HttpResponseMessage Login(HttpRequestMessage request, [FromBody] LoginUserDTO loginUserDTO) { AccountsApiModel accountsWebApiModel = new AccountsApiModel(); TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; if (loginUserDTO.UserName == null) { loginUserDTO.UserName = ""; } if (loginUserDTO.Password == null) { loginUserDTO.Password = ""; } accountsBusinessService = new AccountsBusinessService(accountsDataService); User user = accountsBusinessService.Login( loginUserDTO.UserName, loginUserDTO.Password, out transaction); if (transaction.ReturnStatus == false) { accountsWebApiModel.ReturnMessage = transaction.ReturnMessage; accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel); return(badResponse); } ApplicationInitializationBusinessService initializationBusinessService; initializationBusinessService = new ApplicationInitializationBusinessService(applicationDataService); List <ApplicationMenu> menuItems = initializationBusinessService.GetMenuItems(true, out transaction); if (transaction.ReturnStatus == false) { accountsWebApiModel.ReturnMessage = transaction.ReturnMessage; accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; var badResponse = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel); return(badResponse); } accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.IsAuthenicated = true; accountsWebApiModel.ReturnMessage.Add("Login successful."); accountsWebApiModel.MenuItems = menuItems; accountsWebApiModel.User = user; FormsAuthentication.SetAuthCookie(user.UserId.ToString(), createPersistentCookie: false); var response = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel); return(response); }
public HttpResponseMessage UpdateAccount(HttpRequestMessage request, [FromBody] AccountInfo objAccountInfo) { TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; objAccountInfo.IsAuthenicated = true; accountsBusinessService = new AccountsBusinessService(accountsDataService); taccount account = accountsBusinessService.UpdateAccount( objAccountInfo.AccountID, objAccountInfo.FirstName, objAccountInfo.LastName, objAccountInfo.EmailAddress, objAccountInfo.IsEnabled, objAccountInfo.PostToSlack, objAccountInfo.SlackBotChannel, objAccountInfo.Password, objAccountInfo.Role, out transaction); if (transaction.ReturnStatus == false) { objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); } objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.Account = account; var response = Request.CreateResponse <AccountInfo>(HttpStatusCode.OK, objAccountInfo); return(response); }
public HttpResponseMessage UpdateUser(HttpRequestMessage request, [FromBody] UserDTO updateUserDTO) { Guid userID = new Guid(User.Identity.Name); AccountsApiModel accountsWebApiModel = new AccountsApiModel(); TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; accountsWebApiModel.IsAuthenicated = true; if (updateUserDTO.FirstName == null) { updateUserDTO.FirstName = ""; } if (updateUserDTO.LastName == null) { updateUserDTO.LastName = ""; } if (updateUserDTO.EmailAddress == null) { updateUserDTO.EmailAddress = ""; } if (updateUserDTO.UserName == null) { updateUserDTO.UserName = ""; } if (updateUserDTO.Password == null) { updateUserDTO.Password = ""; } if (updateUserDTO.PasswordConfirmation == null) { updateUserDTO.PasswordConfirmation = ""; } accountsBusinessService = new AccountsBusinessService(accountsDataService); User user = accountsBusinessService.UpdateUser( userID, updateUserDTO.FirstName, updateUserDTO.LastName, updateUserDTO.UserName, updateUserDTO.EmailAddress, updateUserDTO.Password, updateUserDTO.PasswordConfirmation, out transaction); if (transaction.ReturnStatus == false) { accountsWebApiModel.ReturnMessage = transaction.ReturnMessage; accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel); return(badResponse); } accountsWebApiModel.ReturnStatus = transaction.ReturnStatus; accountsWebApiModel.ReturnMessage.Add("User successful updated."); var response = Request.CreateResponse <AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel); return(response); }
public HttpResponseMessage GetAccounts([FromBody] AccountInfo objAccountInfo) { if (objAccountInfo.FirstName == null) { objAccountInfo.FirstName = string.Empty; } if (objAccountInfo.LastName == null) { objAccountInfo.LastName = string.Empty; } if (objAccountInfo.SortDirection == null) { objAccountInfo.SortDirection = string.Empty; } if (objAccountInfo.SortExpression == null) { objAccountInfo.SortExpression = string.Empty; } TransactionalInformation transaction = new TransactionalInformation(); AccountsBusinessService accountsBusinessService; objAccountInfo.IsAuthenicated = true; DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = objAccountInfo.CurrentPageNumber; paging.PageSize = objAccountInfo.PageSize; paging.SortExpression = objAccountInfo.SortExpression; paging.SortDirection = objAccountInfo.SortDirection; if (paging.SortDirection == "") { paging.SortDirection = "DESC"; } if (paging.SortExpression == "") { paging.SortExpression = "FirstName"; } accountsBusinessService = new AccountsBusinessService(accountsDataService); List <taccount> accounts = accountsBusinessService.AccountInquiry(objAccountInfo.FirstName, objAccountInfo.LastName, paging, out transaction); objAccountInfo.Accounts = accounts; objAccountInfo.ReturnStatus = transaction.ReturnStatus; objAccountInfo.ReturnMessage = transaction.ReturnMessage; objAccountInfo.TotalPages = transaction.TotalPages; objAccountInfo.TotalRows = transaction.TotalRows; objAccountInfo.PageSize = paging.PageSize; if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <AccountInfo>(HttpStatusCode.OK, objAccountInfo); return(response); } var badResponse = Request.CreateResponse <AccountInfo>(HttpStatusCode.BadRequest, objAccountInfo); return(badResponse); }