Exemple #1
0
        public async Task <Person> UpdateAsync(Person model)
        {
            var update = await _db.Persons
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Id == model.Id);

            update.FirstName  = model.FirstName;
            update.MiddleName = model.MiddleName;
            update.LastName   = model.LastName;
            update.Gender     = model.Gender;
            update.BirthDate  = model.BirthDate;

            _db.Update(update);

            await _db.SaveChangesAsync();

            return(update);
        }
        public async Task <Account> UpdateAsync(Account model)
        {
            var update = await _db.Accounts
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Id == model.Id);

            update.UserName     = model.UserName;
            update.Password     = model.Password;
            update.Email        = model.Email;
            update.MobilePhone  = model.MobilePhone;
            update.AvatarUri    = model.AvatarUri;
            update.LastUpdateAt = DateTime.UtcNow;

            _db.Update(update);

            await _db.SaveChangesAsync();

            return(update);
        }