public async Task EditCar(int carId, CarDto car, CancellationToken cancellationToken = default) { var carDomain = await _context.Cars.FindAsync(carId); carDomain.CarName = car.CarName; carDomain.YearOFProduction = car.YearOFProduction; carDomain.HorsePower = car.HorsePower; carDomain.NumberOfDoors = car.NumberOfDoors; carDomain.Price = car.Price; carDomain.ImageURL = car.ImageURL; carDomain.ColorID = car.ColorID; _context.Cars.Update(carDomain); await _context.SaveChangesAsync(cancellationToken); }
public async Task EditUser(int userId, UserDto user, CancellationToken cancellationToken = default) { var userDomain = await _context.Users.FindAsync(userId); userDomain.Name = user.Name; userDomain.Surname = user.Surname; userDomain.DateOfBirth = user.DateOfBirth; userDomain.CityID = user.CityID; userDomain.Address = user.Address; userDomain.Username = user.Username; userDomain.Email = user.Email; userDomain.Password = user.Password; _context.Users.Update(userDomain); await _context.SaveChangesAsync(cancellationToken); }
public async Task <int> SaveContact(ContactDto contact, CancellationToken cancellationToken = default) { var contactDomain = new Contact { Id = contact.Id, Name = contact.Name, Email = contact.Email, Subject = contact.Subject, Message = contact.Message }; await _context.Contacts.AddAsync(contactDomain, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(contactDomain.Id); }
public async Task <int> Save(BookedCarDto dto, CancellationToken cancellationToken = default) { var bookedCar = new BookedCar { UserID = 2, CarID = dto.CarID, From = dto.From, To = dto.To, TotalPrice = dto.TotalPrice }; await _context.BookedCars.AddAsync(bookedCar, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(bookedCar.Id); }