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)); } }
/// <summary> /// Pasing data to data access layer for inserting risorse retrieved from controller end. /// </summary> /// <param name="risorseDto"></param> /// <returns></returns> public async Task <string> InsertAsync(ClaimsPrincipal User, RisorseDto risorseDto) { try { // Create new domain object from DTO. Risorse risorse = _mapper.Map <RisorseDto, Risorse>(risorseDto); // Set auditable properties. risorse.RisInsUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisInsTimestamp = DateTime.Now; risorse.RisModUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisModTimestamp = DateTime.Now; risorse.RisCliId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sid"))?.Value; // Execute persistence. _unitOfWork.Risorse.Add(risorse); await _unitOfWork.CompleteAsync(); return(risorse.RisTitolo); } catch (Exception) { throw; } }
public async Task <IActionResult> UpdateRiosorse([FromBody] RisorseDto risorseDto) { try { // Retreiving the newly updated risorse object from bll. await _risorseManager.UpdateAsync(User, risorseDto); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "update", "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, "Update Risorse"); // Returning the error object. return(BadRequest(errorObj)); } }
/// <summary> /// Pasing data to data access layer for updating risorse retrieved from controller end. /// </summary> /// <param name="richiesteDto"></param> /// <returns></returns> public async Task <string> UpdateAsync(ClaimsPrincipal User, RisorseDto risorseDto) { try { //map dto dto to table risorse Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(x => x.RisId == risorseDto.RisId && x.RisCliId == risorseDto.RisCliId); _mapper.Map(risorseDto, risorse); risorse.RisModUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisModTimestamp = DateTime.Now; await _unitOfWork.CompleteAsync(); return(risorse.RisTitolo); } catch (Exception ex) { throw; } }