public void AddCity(CityDTO dto) { var city = new City { Name = dto.Name, Distance = dto.Distance }; _db.Add(city); _db.SaveChanges(); }
public void AddAirplane(AirplaneDTO dto) { var airplane = new Airplane { Distance = dto.Distance, Model = dto.Model, LiftingCapacity = dto.LiftingCapacity, PassengerCapacity = dto.PassengerCapacity }; _db.Add(airplane); _db.SaveChanges(); }
public async Task <UserDTO> PostAsync(UserDTO entity) { if (string.IsNullOrEmpty(entity.Password) || string.IsNullOrEmpty(entity.Login)) { throw new ArgumentException("Login and password are required"); } var user = mapper.Map <UserDTO, User>(entity); byte[] passwordHash, passwordSalt; CreatePasswordHash(entity.Password, passwordHash: out passwordHash, passwordSalt: out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; user.Role = Role.User; context.Add(user); await context.SaveChangesAsync(); return(mapper.Map <User, UserDTO>(user)); }