public async Task <IdentityResult> ChangePassword(int ID, ChangePasswordRequest request)
        {
            var entity = await _context.Set <Korisnik>().FindAsync(ID);

            var user = await _userManager.FindByEmailAsync(entity.Email);

            return(await _userManager.ChangePasswordAsync(user, request.OldPassword, request.NewPassword));
        }
Example #2
0
        public async Task <bool> Delete(int id)
        {
            var entity = await _context.Set <Rezervacija>().FindAsync(id);

            try
            {
                _context.Set <Rezervacija>().Remove(entity);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public virtual async Task <PagedResponse <TModel> > Get(TSearch search, PaginationQuery pagination)
        {
            var query = _context.Set <TDatabase>()
                        .AsNoTracking()
                        .AsQueryable();

            query = ApplyFilter(query, search);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            query = query.Skip(skip).Take(pagination.PageSize);

            var list = await query.ToListAsync();

            var pagedResponse = await GetPagedResponse(_mapper.Map <List <TModel> >(list), search, pagination);

            return(pagedResponse);
        }
Example #4
0
        public virtual async Task <TModel> Insert(TInsert request)
        {
            var entity = _mapper.Map <TDatabase>(request);

            _context.Set <TDatabase>().Add(entity);
            await _context.SaveChangesAsync();

            return(_mapper.Map <TModel>(entity));
        }
        public async override Task <PagedResponse <KategorijaResponse> > Get(KategorijaSearchRequest search, PaginationQuery pagination)
        {
            var query = _context.Set <Kategorija>()
                        .AsNoTracking()
                        .AsQueryable();

            ApplyFilter(query, search);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            query = query.Skip(skip).Take(pagination.PageSize);

            var list = await query.ToListAsync();

            var pagedResponse = await GetPagedResponse(_mapper.Map <List <KategorijaResponse> >(list), search, pagination);

            return(pagedResponse);
        }
        public async override Task <PagedResponse <JeloResponse> > Get(JeloSearchRequest search, PaginationQuery pagination)
        {
            var query = _context.Set <Jelo>()
                        .Include(i => i.Kategorija)
                        .AsNoTracking()
                        .AsQueryable();

            query = ApplyFilter(query, search);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            query = query.Skip(skip).Take(pagination.PageSize);

            var list = await query.OrderBy(s => s.Naziv).ToListAsync();

            var pagedResponse = await GetPagedResponse(_mapper.Map <List <JeloResponse> >(list), search, pagination);

            return(pagedResponse);
        }
        public async override Task <PagedResponse <NarudzbaDetaljiResponse> > Get(NarudzbaDetaljiSearchRequest search, PaginationQuery pagination)
        {
            var query = _context.Set <NarudzbaDetalji>()
                        .Include(j => j.Jelo)
                        .Include(n => n.NarudzbaID)
                        .AsNoTracking()
                        .AsQueryable();

            query = ApplyFilter(query, search);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            query = query.Skip(skip).Take(pagination.PageSize);

            var list = await query.ToListAsync();

            var pagedResponse = await GetPagedResponse(_mapper.Map <List <NarudzbaDetaljiResponse> >(list), search, pagination);

            return(pagedResponse);
        }
        public async override Task <PagedResponse <NarudzbaResponse> > Get(NarudzbaSearchRequest search, PaginationQuery pagination)
        {
            var query = _context.Set <Narudzba>()
                        .Include(s => s.StatusDostave)
                        .Include(k => k.Korisnik)
                        .AsNoTracking()
                        .OrderByDescending(i => i.DatumNarudzbe)
                        .AsQueryable();

            query = ApplyFilter(query, search);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            query = query.Skip(skip).Take(pagination.PageSize);

            var list = await query.ToListAsync();

            var pagedResponse = await GetPagedResponse(_mapper.Map <List <NarudzbaResponse> >(list), search, pagination);

            return(pagedResponse);
        }
Example #9
0
        public virtual List <TModel> Get(TSearch search)
        {
            var list = _context.Set <TDatabase>().ToList();

            return(_mapper.Map <List <TModel> >(list));
        }