Exemplo n.º 1
0
        public async Task <IActionResult> InsertRichieste([FromBody] RichiesteDto richiesteDto)
        {
            try
            {
                // Retreiving the newly created richieste object from bll.
                var categories = await _richiesteManager.InsertAsync(User, richiesteDto);

                // 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", "richieste");
                // 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 Richieste");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Pasing data to data access layer for inserting richieste retrieved from controller end.
        /// </summary>
        /// <param name="richiesteDto"></param>
        /// <returns></returns>
        public async Task <string> InsertAsync(ClaimsPrincipal User, RichiesteDto richiesteDto)
        {
            try
            {
                //map dto to table richieste
                Richieste richieste = _mapper.Map <RichiesteDto, Richieste>(richiesteDto);

                richieste.RichInsTimestamp = DateTime.Now;
                richieste.RichModTimestamp = DateTime.Now;
                richieste.RichData         = DateTime.Now;
                richieste.RichInsUteId     = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value;
                richieste.RichModUteId     = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value;
                richieste.RichCliId        = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sid"))?.Value;

                richieste.RichAttiva = "S";

                // Passing data to dal
                var richId = await _unitOfWork.Richieste.InsertRichieste(richieste);

                return(richId);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> UpdateRuolo([FromBody] RichiesteDto richiesteDto)
        {
            try
            {
                // Retreiving the newly updated richieste object from bll.
                await _richiesteManager.UpdateAsync(User, richiesteDto);

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

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Pasing data to data access layer for updating richieste retrieved from controller end.
        /// </summary>
        /// <param name="richiesteDto"></param>
        /// <returns></returns>
        public async Task <string> UpdateAsync(ClaimsPrincipal User, RichiesteDto richiesteDto)
        {
            try
            {
                //map dto dto to table termini
                Richieste richieste = await _unitOfWork.Richieste
                                      .FirstOrDefaultAsync(c => c.RichId.Equals(richiesteDto.RichId) &&
                                                           c.RichCliId.Equals(richiesteDto.RichCliId));

                _mapper.Map(richiesteDto, richieste);

                richieste.RichModTimestamp = DateTime.Now;
                richieste.RichModUteId     = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value;

                await _unitOfWork.CompleteAsync();

                return(richieste.RichId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }