public async Task <IActionResult> Post([FromBody] CreateUser createUser) { var user = new User { UserName = createUser.UserName, UserEmail = createUser.UserEmail, BirthDate = createUser.BirthDate, RegistrationDate = DateTime.UtcNow, IsBannedUser = false, UserStatus = UserStatus.User.ToString() }; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(Created(user.UserId.ToString(), new UserViewModel { UserId = user.UserId, UserName = user.UserName, UserEmail = user.UserEmail, Address = user.Address, RegistrationDate = user.RegistrationDate, BirthDate = user.BirthDate, IsBannedUser = user.IsBannedUser, UserStatus = user.UserStatus })); }
public async Task <IActionResult> Post([FromBody] CreateWorkshop createWorkshop) { var workshop = new Workshop { Address = createWorkshop.Address, EmployeeCount = createWorkshop.EmployeeCount }; await _context.AddAsync(workshop); await _context.SaveChangesAsync(); return(Created(workshop.WorkshopId.ToString(), new WorkshopViewModel { WorkshopId = workshop.WorkshopId, Address = workshop.Address, EmployeeCount = workshop.EmployeeCount })); }
public async Task <int> AddUser(Domain.User.User user) { var userDAO = new DAO.User { UserName = user.UserName, UserEmail = user.UserEmail, Address = user.Address, RegistrationDate = user.RegistrationDate, BirthDate = user.BirthDate, IsBannedUser = user.IsBannedUser, UserStatus = user.UserStatus }; await _context.AddAsync(userDAO); await _context.SaveChangesAsync(); return(userDAO.UserId); }
public async Task <IActionResult> Post([FromBody] CreateBicycle createBicycle) { var bicycle = new Bicycle { UserId = createBicycle.UserId, ProductionDate = createBicycle.ProductionDate, Type = createBicycle.Type }; await _context.AddAsync(bicycle); await _context.SaveChangesAsync(); return(Created(bicycle.BicycleId.ToString(), new BicycleViewModel { UserId = bicycle.UserId, ProductionDate = bicycle.ProductionDate, Type = bicycle.Type })); }