public async Task <IActionResult> PutUserInfo(int id, UserInfo userInfo) { if (id != userInfo.Id) { return(BadRequest()); } _context.Entry(userInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProducts(int id, Products products) { if (id != products.Id) { return(BadRequest()); } _context.Entry(products).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> Add(AppUser user) { var currentUser = _dbContext.AppUsers.FirstOrDefault(p => p.Id == user.Id); var userClaim = _dbContext.AppUsers.Add(user); return(await _dbContext.SaveChangesAsync()); }
/// <summary> /// Yeni Personel Ekler. /// </summary> public async Task AddPersonAsync(PersonAddDto personAddDto) { var newPerson = new Person { TCNumber = personAddDto.TCNumber, Name = personAddDto.Name, Surname = personAddDto.Surname, PhoneNumber = personAddDto.PhoneNumber, Mail = personAddDto.Mail, }; _dbContext.Persons.Add(newPerson); await _dbContext.SaveChangesAsync(); var currentUser = await _dbContext.Persons.Where(p => !p.IsDeleted && p.TCNumber == personAddDto.TCNumber) .SingleOrDefaultAsync(); var newAppUser = new UserRegisterDto { TCNumber = currentUser.TCNumber, FirstName = currentUser.Name, LastName = currentUser.Surname, Email = currentUser.Mail, Password = random.Next(99999, 1000000).ToString() }; _authService.Register(newAppUser); }
public Task <int> Add(AppUser user) { _dbContext.Add(user); return(_dbContext.SaveChangesAsync()); }