/// <summary> /// Gets list object of the table CompanyApplication. /// </summary> /// <param name="dtoCompanyApplication">List that contains the DTOs from CompanyApplication table that filter the query.</param> /// <returns>List object of the table CompanyApplication.</returns> /// <author>Mauricio Suarez.</author> public List <CompanyApplicationDto> GetCompanyApplication(CompanyApplicationDto dtoCompanyApplication) { List <CompanyApplicationDto> listFilterCompanyApplication = new List <CompanyApplicationDto>(); listFilterCompanyApplication.Add(dtoCompanyApplication); return(this.ExecuteGetCompanyApplication(null, listFilterCompanyApplication)); }
public ResultUserAuthenticationDto GetAuthentication(string userName, string password) { userName = Crypto.DecryptStringAes(userName); password = Crypto.DecryptStringAes(password); BasicAuthenticationDto dtoBasicAuthentication = this.GetBasicAuthentication(userName, password, null, null, "not apply"); ResultUserAuthenticationDto dtoResultUserAuthentication = new ResultUserAuthenticationDto(); dtoResultUserAuthentication.AuthenticationCod = dtoBasicAuthentication.AuthenticationCod; dtoResultUserAuthentication.MessageAuthentication = dtoBasicAuthentication.MessageAuthentication; if (dtoResultUserAuthentication.AuthenticationCod == Convert.ToInt16(AuthenticationCode.Success)) { dtoResultUserAuthentication.UserApplication = Mapper.Map <UserApplicationDto, ResultUserDto>(dtoBasicAuthentication.User); CompanyApplicationDto dtoApplication = new CompanyApplicationDto(); dtoApplication.IdCompany = dtoBasicAuthentication.User.IdCompany; dtoApplication.ReferenceTableApplication = true; //list aplication dtoResultUserAuthentication.ListApplication = CompanyApplicationRepository.GetCompanyApplication(dtoApplication).Select(data => Mapper.Map <ApplicationDto, ResultApplicationDto>(data.Application)).ToList(); dtoResultUserAuthentication.ListApplication.ForEach(data => { //set ticket by app data.Ticket = GetServiceToken(); }); } return(dtoResultUserAuthentication); }
/// <summary> /// Save or update records for the table /// </summary> /// <param name="dtoCompanyApplication">List of data to store CompanyApplication.</param> /// <returns>The result of processing the list.</returns> /// <author>Mauricio Suárez.</author> public List <CompanyApplicationDto> SaveCompanyApplication(CompanyApplicationDto dtoCompanyApplication) { List <CompanyApplicationDto> listDataCompanyApplication = new List <CompanyApplicationDto>(); listDataCompanyApplication.Add(dtoCompanyApplication); return(this.SaveCompanyApplication(listDataCompanyApplication)); }
private BasicAuthenticationDto GetBasicAuthentication(string userName, string password, long?idCompany, long?idApplication, string token) { bool authenticationError = false; BasicAuthenticationDto dtoResultUserAuthentication = new BasicAuthenticationDto(); dtoResultUserAuthentication.AuthenticationCod = Convert.ToInt16(AuthenticationCode.AccessDenied); dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; if (token != "not apply") { if (this.GetServiceToken() != token) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } } if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password)) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } if (authenticationError == false) { UserApplicationDto dtoUserApplication = new UserApplicationDto(); dtoUserApplication.UserName = userName; dtoUserApplication.UserPassword = password; dtoUserApplication.IdCompany = idCompany; dtoUserApplication.State = true; dtoUserApplication = UserApplicationRepository.GetUserApplication(dtoUserApplication).FirstOrDefault(); if (dtoUserApplication == null) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } else { dtoUserApplication.UserPassword = null; if (dtoUserApplication.EffectiveDate != null && dtoUserApplication.EffectiveDate >= DateTime.Now) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied - Limit Date"; } else { dtoResultUserAuthentication.User = dtoUserApplication; } if (idCompany != null && authenticationError == false) { if (dtoResultUserAuthentication.User.IdCompany != idCompany) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } } if (idApplication != null && authenticationError == false) { CompanyApplicationDto dtoApplication = new CompanyApplicationDto(); dtoApplication.IdApplication = idApplication; dtoApplication.IdCompany = dtoResultUserAuthentication.User.IdCompany; List <CompanyApplicationDto> listApplicationDto = CompanyApplicationRepository.GetCompanyApplication(dtoApplication); if (listApplicationDto.Count != 1) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied";// - ApplicationNotFound"; } } } } if (authenticationError == false) { dtoResultUserAuthentication.AuthenticationCod = Convert.ToInt16(AuthenticationCode.Success); dtoResultUserAuthentication.MessageAuthentication = "Success"; } return(dtoResultUserAuthentication); }