コード例 #1
0
        public async Task <IActionResult> InsertTermini(TerminiDto terminiDto)
        {
            try
            {
                // Checking whether the dto object is null or not.
                if (terminiDto == null)
                {
                    return(NotFound());
                }
                await _terminiManager.InsertAsync(terminiDto);

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

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
コード例 #2
0
        public async Task <IActionResult> GetNextTermini(TerminiDto terminiDto)
        {
            try
            {
                // Retrieving th termni details by passing the termini name and client id.;
                var terminiDtos = await _terminiManager.FindNextTerminiAsync(terminiDto);

                if (terminiDtos == null)
                {
                    return(NotFound());
                }
                // creating the azioni object passing the related details and description.
                var azioniDto = _utilityManager.GetAzioniDtoObject(User, "get", "next termini");
                // 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 termini detais");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
コード例 #3
0
ファイル: TerminiManager.cs プロジェクト: mmaasum/dotnet-core
        public async Task <TerminiDto> FindNextTerminiAsync(TerminiDto terminiDto)
        {
            try
            {
                // Fetching data from dal by passing parameter.
                //Termini currentTermini = await _unitOfWork.Termini.FirstOrDefaultAsync
                //                                (c => c.TerCliId.Equals(terminiDto.TerCliId)
                //                                   && c.Termine.Equals(terminiDto.Termine)
                //                                   && c.TerLingua.Equals(terminiDto.TerLingua));

                Termini nextTermini = (await _unitOfWork.Termini.FindInOrderAsync
                                           ((c => c.TerCliId.Equals(terminiDto.TerCliId) &&
                                             c.TerStato.Equals(terminiDto.TerStato) &&
                                             c.TerLingua.Equals(terminiDto.TerLingua)),
                                           o => o.TerInsTimestamp, OrderType.Ascending)
                                       ).FirstOrDefault();

                // Returning the retrieved data to controller end by mapping into dto object.
                return(_mapper.Map <Termini, TerminiDto>(nextTermini));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
ファイル: TerminiManager.cs プロジェクト: mmaasum/dotnet-core
        public async Task <string> InsertAsync(TerminiDto terminiDto)
        {
            try
            {
                // Map dto to termini domain model.
                Termini termini = _mapper.Map <TerminiDto, Termini>(terminiDto);

                termini.TerInsTimestamp = DateTime.Now;
                termini.TerModTimestamp = DateTime.Now;

                _unitOfWork.Termini.Add(termini);
                await _unitOfWork.CompleteAsync();

                return(termini.Termine);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #5
0
ファイル: TerminiManager.cs プロジェクト: mmaasum/dotnet-core
        public async Task <string> UpdateAsync(TerminiDto terminiDto)
        {
            try
            {
                // Retrieving the termini object based on termini dto attributes value.
                var termini = await _unitOfWork.Termini.FirstOrDefaultAsync(c => c.Termine.Equals(terminiDto.Termine) && c.TerCliId.Equals(terminiDto.TerCliId));

                // Map dto dto to termini domain model
                _mapper.Map(terminiDto, termini);

                termini.TerModTimestamp = DateTime.Now;

                await _unitOfWork.CompleteAsync();

                return(termini.Termine);
            }
            catch (Exception)
            {
                throw;
            }
        }