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 <int> UpdateData(AziendeClientiFinaleDto aziendeClientiFinaleDto) { // Implementing try-catch block. try { // Retrieving the current aziende client finale record by matching through several criteria. var clientFinale = await _unitOfWork.AziendeClientiFinali .FirstOrDefaultAsync(u => u.ClifinId.Equals(aziendeClientiFinaleDto.ClifinId) && u.ClifinCliId.Equals(aziendeClientiFinaleDto.ClifinCliId)); aziendeClientiFinaleDto.ClifinInsTimestamp = clientFinale.ClifinInsTimestamp; _mapper.Map(aziendeClientiFinaleDto, clientFinale); clientFinale.ClifinModTimestamp = DateTime.Now; await _unitOfWork.CompleteAsync(); return(clientFinale.ClifinId); } catch (Exception ex) { // throwing an exception if there's any. throw; } }
public async Task <IActionResult> UpdateAziendeClientiFinale([FromBody] AziendeClientiFinaleDto aziendeClientiFinaleDto) { try { // Checking whether the updatable object is null if (aziendeClientiFinaleDto == null) { // Return 404 error for null data. return(NotFound()); } // Calling the update metho of bll which will pass the object to the dal // to update the record in the database. await _clientFinaleManager.UpdateData(aziendeClientiFinaleDto); // creating the azioni object passing the related details and description. var azioniDto = _utilityManager.GetAzioniDtoObject(User, "update", "aziende_client_finale"); // 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 Aziende"); // Returning the error object. return(BadRequest(errorObj)); } }
public async Task <int> InsertData(AziendeClientiFinaleDto aziendeClientiFinaleDto) { try { // Converting to aziende client finale from dto object to pass into dal. var clientFinale = _mapper.Map <AziendeClientiFinaleDto, AziendeClientiFinali>(aziendeClientiFinaleDto); _unitOfWork.AziendeClientiFinali.Add(clientFinale); await _unitOfWork.CompleteAsync(); return(clientFinale.ClifinId); } catch (Exception ex) { // throwing an exception if there's any. throw; } }