public async Task <IActionResult> PostAziende(AziendeDto aziendeDto) { try { if (aziendeDto == null) { return(NotFound()); } var azid = await _aziendeManager.InsertAziende(aziendeDto); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "add", "aziende"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); aziendeDto.AzId = azid; return(Ok(aziendeDto)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Insert Aziende"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> LogOperationsByClientId(string clientid, int counter) { try { var logOperazionis = await _operazioniManager.GetAllLogOperazioniDataByCliId(clientid, counter); if (logOperazionis == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "log operazioni"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(logOperazionis)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get Log Operazioni based on client id"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <ActionResult> FindSediAziendeBySedeId(int sedeId) { try { var sediAziende = await _sediAziendeManager.FindBySedeIdAsync(sedeId); if (sediAziende == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "Sedi Aziende"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(sediAziende)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get Sedi Aziende"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> InsertAziendeClientiFinale([FromBody] AziendeClientiFinaleDto aziendeClientiFinaleDto) { // Implementing try-catch block. try { // Checking whether the form data is null if (aziendeClientiFinaleDto == null) { // Returning 404 error for null return(NotFound()); } // calling the insert method of bll that will pass the object to dal // to create a new aziende client finale. var returnedId = await _clientFinaleManager.InsertData(aziendeClientiFinaleDto); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "add", "aziende_client_finale"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(returnedId)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Insert Aziende"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> PostUtenti([FromBody] UtentiDto utentiDto) { try { if (utentiDto == null) { return(NotFound()); } var isValidPass = _userManager.IsValidPass(utentiDto.UtePassword); if (!isValidPass) { var result = new { error = "Validation Failed", error_type = "", message = "Password should have 1 digit, 1 symbol, 1 capital letter and 1 small letter" }; return(BadRequest(result)); } //var userHasSamePassForSameUsername = _talentBllWrapper.UtentiBll.HasSamePassForSameUsername(utentiDto.UteId, utentiDto.UtePassword); var userHasSamePassForSameUsername = await _userManager.HasSamePassForSameUsername(utentiDto.UteId, utentiDto.UtePassword); if (userHasSamePassForSameUsername) { var result = new { error = "Validation Failed", error_type = "", message = "There's a user having same username and password for some other client" }; return(BadRequest(result)); } utentiDto.UteInsUteId = this.LoggedInUserId(); await _userManager.Insert(utentiDto, utentiDto.UtentiAbilitazioniDto); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "add", "utenti"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok()); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Insert new Utenti"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> CountMasterFilterUtentiByFilterId(int filterId) { try { // passing the filter id to retrieve the number of record found for that filter. var data = await _globalGridManager.CountMasterFilterUtentiByFilterIdAsync(filterId); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "Count Master Filter User Info By Filter" + ""); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(data)); } catch (Exception x) { var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Count Master Filter User Info By Filter"); if (x.Message == "Token Expired") { return(Unauthorized()); } return(BadRequest(errorObj)); } }
public async Task <IActionResult> InsertRisorse([FromBody] RisorseDto risorseDto) { try { // Retreiving the newly created richieste object from bll. var categories = await _risorseManager.InsertAsync(User, risorseDto); // Null Exception handling code block if (categories == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "add", "risorse"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok()); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Insert new Risorse"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { ActionExecutedContext resultContext = await next(); var user = context.HttpContext.User; if (resultContext.Exception != null) { var azioniDto = _utilityManager.GetAzioniDtoObject(user, _type, _description); await _azioniManager.AzioniInsert(azioniDto); } }
public async Task <IActionResult> GetFindByAllContattiByContAzSedeId(int contAzSedeId) { try { var data = await _contattiManager.GetFindByAllContattiByContAzSedeIdAsync(User, contAzSedeId); if (data == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "tipi contatto"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(data)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get Tipi Contatto"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> GetMailModelObj(string langName) { try { // retrieving the list of data by passing the ris_id var categories = await _hardSkillManager.GetMailModelAsync(User, langName); if (categories == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "mail model data"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(categories)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get Mail Mail Model Data"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> GetSchedule(int risId, string langName) { try { // passing the ridId and language name to business logic layer to retreive the list data. var categories = await _softSkillManager.GetSavedWsResultByRisIdAsync(risId, langName); // Null Reference handling. if (categories == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "saved web service result"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(categories)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get saved web service result."); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> LaunchSpItpFindResource( string name = null, string surname = null, string email = null, string phone = null, string date_of_birth = null, string cities = null, string keyword_skill1 = null, string cli_id = null, string indebug = null ) { //return Ok(); try { var categories = await _robotManager.LaunchSpItpFindResourceDataAsync ( cli_id, name, surname, email, phone, date_of_birth, cities, keyword_skill1, indebug ); if (categories == null) { return(NotFound()); } // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "launch SP [Sp_schedulazione_residuo_cv] "); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(categories)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "launch SP [Sp_Itp_Find_Resource] "); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> PutRuoloAbilitazione([FromBody] List <RuoliTipiAbilitazioneDto> ruoliTipiAbilitazioneDtoList, int userAuthChangedConfirmation) { try { if (ruoliTipiAbilitazioneDtoList == null) { return(NotFound()); } await _roleManager.UpdateRoleAuthData(ruoliTipiAbilitazioneDtoList, userAuthChangedConfirmation); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "update", "ruolo_abilitazione"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok()); } catch (Exception x) { var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Update Role Authentication List"); return(BadRequest(errorObj)); } }
public async Task <IActionResult> postAzioni([FromBody] AzioniDto azioniDto) { try { if (azioniDto == null) { return(NotFound()); } await _azioniManager.AzioniInsert(azioniDto); return(Ok()); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Insert Azioni"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> GetLastAnalysisInfo(string cliId, string uteId) { try { var terminiDtos = await _terminiManager.GetLastAnalysisInfoData(cliId, uteId); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "termini last analysis"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(terminiDtos)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get all termini by sinonimo"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> GetStatiRichListRisDescr(string langName) { try { var data = await _richiesteManager.GetStatiRichListRisDescrAsync(langName); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "Stati_Rich_List_Ris_Descr"); // logging the activity record by the user. await _azioniManager.AzioniInsert(azioniDto); return(Ok(data)); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Get Stati_Rich_List_Ris_Descr"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <IActionResult> Login([FromBody] UserLoginDto user) { if (!ModelState.IsValid) { return(NotFound(ModelState)); } try { var tipo = "login_ok"; // Check user valid or not var checkuser = await _authManager.ValidateUserAsync(user); HttpContext httpContext = this.HttpContext; var ip = httpContext.Connection.RemoteIpAddress.ToString(); // Getting the browser name var userAgent = httpContext.Request.Headers["User-Agent"]; string uaString = Convert.ToString(userAgent[0]); var uaParser = Parser.GetDefault(); ClientInfo c = uaParser.Parse(uaString); var description = $"IP -> {ip} . Client -> {c.UA} . OS -> {c.OS}"; var authHeader = Request.Headers["Authorization"].ToString(); AzioniDto azioniDto = CreateAzioniObj(description, tipo, user.UteId, user.UteCliId, user.UtePassword); if (checkuser.UteId == null) { tipo = "login_ko"; azioniDto = CreateAzioniObj(description, tipo, user.UteId, user.UteCliId, user.UtePassword); await _azioniManager.AzioniInsert(azioniDto); var result = new { error = "Login failed", error_type = "usrmsg_err", message = "L1008_wrongcredentials" }; return(BadRequest(result)); } // Find out five times failed login attempts var userHas5FailedAttempts = await _authManager.Has5ConsecutiveFailedAttemptsWithin5Miniutes(checkuser.UteId); if (userHas5FailedAttempts) { await _authManager.LockUser(user.UteId); tipo = "login_ko"; azioniDto = CreateAzioniObj(description, tipo, user.UteId, user.UteCliId, user.UtePassword); await _azioniManager.AzioniInsert(azioniDto); var result = new { error = "Login failed", error_type = "usrmsg_err", message = "L1002_userLocked" }; return(BadRequest(result)); } // Checking whether the user status is active or not if (checkuser.UteAttivo == "N") { tipo = "login_ko"; azioniDto = CreateAzioniObj(description, tipo, user.UteId, user.UteCliId, user.UtePassword); await _azioniManager.AzioniInsert(azioniDto); var result = new { error = "Login failed", error_type = "usrmsg_err", message = "L1001_userInactive" }; return(BadRequest(result)); } await _azioniManager.AzioniInsert(azioniDto); HttpContext.Session.SetObjectAsJson("userDto", checkuser); var userProfile = await _userManager.FindUserProfileData(user.UteId, user.UteCliId); return(Ok(new { Token = checkuser.Token, userAuthList = checkuser.userAuthList, Email = checkuser.UteMail, UserProfile = userProfile })); } catch (Exception x) { // Code block of Exception handling and logging into log_operazione table. var errorObj = await _utilityManager.ReturnErrorObj(x, User, "login_ko"); // Returning the error object. return(BadRequest(errorObj)); } }