Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateSediAziende([FromBody] SediAziendeDto sediAziendeDto)
        {
            try
            {
                // Checking whether the updatable object is null
                if (sediAziendeDto == 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.
                var returnedId = await _sediAziendeManager.UpdateAsync(sediAziendeDto);

                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "update", "sedi_aziende");
                // 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, "Update Sedi Aziende");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> InsertSediAziende([FromBody] SediAziendeDto sediAziendeDto)
        {
            // Implementing try-catch block.
            try
            {
                // Checking whether the form data is null
                if (sediAziendeDto == 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 sedi aziende.
                var returnedId = await _sediAziendeManager.InsertAsync(sediAziendeDto);

                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "add", "sedi_aziende");
                // 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 new Sedi Aziende");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Ejemplo n.º 3
0
        public async Task <int> InsertAsync(SediAziendeDto sediAziendeDto)
        {
            try
            {
                var sediAziende = _mapper.Map <SediAziendeDto, SediAziende>(sediAziendeDto);
                _unitOfWork.SediAziende.Add(sediAziende);
                await _unitOfWork.CompleteAsync();

                return(sediAziende.AzsedeId);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public async Task <int> UpdateAsync(SediAziendeDto sediAziendeDto)
        {
            try
            {
                var sediAziende = await _unitOfWork.SediAziende
                                  .FirstOrDefaultAsync(u => u.AzsedeId.Equals(sediAziendeDto.AzsedeId) &&
                                                       u.AzsedeCliId.Equals(sediAziendeDto.AzsedeCliId));


                _mapper.Map(sediAziendeDto, sediAziende);
                await _unitOfWork.CompleteAsync();

                return(sediAziende.AzsedeId);
            }
            catch (Exception ex)
            {
                throw;
            }
        }