Exemple #1
0
        public async Task <ActionResponse <IssuedPrintDto> > Increment(IssuedPrintDto entityDto)
        {
            try
            {
                var targetYear = new DateTime(entityDto.PrintDate.Year, 1, 1);

                var entityToUpdate = unitOfWork.GetGenericRepository <IssuedPrint>()
                                     .GetAllAsQueryable()
                                     .Where(e => e.StudentId == entityDto.StudentId &&
                                            e.EducationProgramId == entityDto.EducationProgramId &&
                                            e.DateCreated >= targetYear && e.DateCreated <= targetYear.AddYears(1).AddTicks(-1))
                                     .FirstOrDefault();

                entityToUpdate.PrintNumber += 1;

                unitOfWork.Save();

                return(await ActionResponse <IssuedPrintDto>
                       .ReturnSuccess(mapper.Map <IssuedPrint, IssuedPrintDto>(entityToUpdate)));
            }
            catch (Exception)
            {
                return(await ActionResponse <IssuedPrintDto> .ReturnError("Greška prilikom inkrementa izdanog printa."));
            }
        }
Exemple #2
0
 public async Task <ActionResponse <IssuedPrintDto> > Update(IssuedPrintDto entityDto)
 {
     try
     {
         var entityToUpdate = mapper.Map <IssuedPrintDto, IssuedPrint>(entityDto);
         unitOfWork.GetGenericRepository <IssuedPrint>().Update(entityToUpdate);
         unitOfWork.Save();
         return(await ActionResponse <IssuedPrintDto>
                .ReturnSuccess(mapper.Map <IssuedPrint, IssuedPrintDto>(entityToUpdate)));
     }
     catch (Exception)
     {
         return(await ActionResponse <IssuedPrintDto> .ReturnError("Greška prilikom ažuriranja izdanog printa."));
     }
 }
 public async Task <ActionResponse <IssuedPrintDto> > Increment([FromBody] IssuedPrintDto entityDto) => await issuedPrintService.Increment(entityDto);
 public async Task <ActionResponse <IssuedPrintDto> > Update([FromBody] IssuedPrintDto entityDto) => await issuedPrintService.Update(entityDto);
 public async Task <ActionResponse <int> > GetForStudentAndProgramTotalDuplicates(IssuedPrintDto request) => await issuedPrintService.GetForStudentAndProgramTotalDuplicates(request);
 public async Task <ActionResponse <List <IssuedPrintDto> > > GetForStudentAndProgram(IssuedPrintDto request) => await issuedPrintService.GetForStudentAndProgram(request);
Exemple #7
0
        public async Task <ActionResponse <int> > GetForStudentAndProgramTotalDuplicates(IssuedPrintDto entityDto)
        {
            try
            {
                var result = unitOfWork.GetGenericRepository <IssuedPrint>()
                             .ReadAllActiveAsQueryable()
                             .Where(e => e.StudentId == entityDto.StudentId && e.EducationProgramId == entityDto.EducationProgramId)
                             .Sum(e => e.PrintNumber);

                return(await ActionResponse <int> .ReturnSuccess(result));
            }
            catch (Exception)
            {
                return(await ActionResponse <int> .ReturnError("Greška prilikom dohvata broja duplikata za polaznika."));
            }
        }
Exemple #8
0
        public async Task <ActionResponse <List <IssuedPrintDto> > > GetForStudentAndProgram(IssuedPrintDto entityDto)
        {
            try
            {
                var query = unitOfWork.GetGenericRepository <IssuedPrint>()
                            .ReadAllActiveAsQueryable()
                            .Where(e => e.StudentId == entityDto.StudentId && e.EducationProgramId == entityDto.EducationProgramId);

                var entity = mapper.ProjectTo <IssuedPrintDto>(query).ToList();

                return(await ActionResponse <List <IssuedPrintDto> > .ReturnSuccess(entity));
            }
            catch (Exception)
            {
                return(await ActionResponse <List <IssuedPrintDto> > .ReturnError("Greška prilikom dohvata izdanih duplikata za polaznika."));
            }
        }