Exemple #1
0
        public async Task <Package> PutPackagesAsync(int id, PackageEntity package)
        {
            if (id != package.Id)
            {
                return(null);
            }
            _context.Entry(package).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(_mapper.Map <Package>(package));
        }
Exemple #2
0
        public async Task <Member> PutMembersAsync(int id, MemberEntity member)
        {
            if (id != member.Id)
            {
                return(null);
            }
            _context.Entry(member).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(_mapper.Map <Member>(member));
        }
Exemple #3
0
        public async Task <Trainer> PutTrainersAsync(int id, TrainerEntity trainer)
        {
            if (id != trainer.Id)
            {
                return(null);
            }
            try
            {
                _context.Entry(trainer).State = EntityState.Modified;
                var user = await _context.Users.Where(x => x.Username == trainer.Username).FirstOrDefaultAsync();

                user.Password = trainer.Password;

                _context.Entry(user).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(_mapper.Map <Trainer>(trainer));
        }