Beispiel #1
0
        public async Task <TreningModel> Update(int id, TreningModel model)
        {
            try
            {
                var trening = _context.Trening
                              .Where(k => k.Id == id)
                              .FirstOrDefault();
                _context.Set <Trening>().Attach(trening);
                _context.Set <Trening>().Update(trening);

                //_mapper.Map(model, kurs); ne prolazi zbog id-a pa cu manual
                trening.Naziv         = model.Naziv;
                trening.SkraceniNaziv = model.SkraceniNaziv;
                trening.Opis          = model.SkraceniNaziv;

                await _context.SaveChangesAsync();

                var returnModel = _mapper.Map <TreningModel>(trening);
                return(returnModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public virtual List <TModel> Get(TSearch search)
        {
            var list = _context.Set <TDatabase>().ToList();

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