public string Execute(IList <string> parameters) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); var departureDate = DateTime.Parse(parameters[0]); var destination = parameters[1]; var duration = int.Parse(parameters[2]); var carAvailableAgainAfter = departureDate.AddDays(duration + 1); var carId = orderComposer.SelectedCar.Id; var user = orderComposer.SelectedUser; var order = new Order() { CarId = carId, User = (User)user, DepartureDate = departureDate, ArrivalDate = departureDate.AddDays(duration) }; context.Orders.Add(order); context.SaveChanges(); string result = string.Format("You have succesfully booked your AutoRent car! It would be waiting for you on" + $"{order.DepartureDate.ToString()}" + $"{order.Car.Office.Address.ToString()}, {order.Car.Office.City.ToString()}."); return(result); }
public string Execute(IList <string> parameters) { Enum.TryParse(parameters[5], out UserStatus parsedStatus); var firstName = parameters[0]; var familyName = parameters[1]; var pin = parameters[2]; var drivingLicenseNumber = parameters[3]; var phoneNumber = parameters[4]; var status = parsedStatus; var user = new User() { FirstName = firstName, FamilyName = familyName, PIN = pin, DrivingLicenseNumber = drivingLicenseNumber, PhoneNumber = phoneNumber, }; context.Users.Add(user); context.SaveChanges(); return($"User with ID {this.context.Users.Count()} was created."); }
public string Execute(IList <string> parameters) { var carId = int.Parse(parameters[0]); var selectedCar = context.Cars.FirstOrDefault(c => c.Id == carId); context.Cars.Remove(selectedCar); context.SaveChanges(); return($"Car with ID {carId} was deleted."); }
public string Execute(IList <string> parameters) { var city = parameters[0]; var address = parameters[1]; var office = new Office() { City = city, Address = address, }; context.Offices.Add(office); context.SaveChanges(); return($"Office with ID {this.context.Offices.Count()} was created."); }
public string Execute(IList <string> parameters) { var make = parameters[0]; var model = parameters[1]; var type = parameters[2]; var price = decimal.Parse(parameters[3]); var isAvailable = bool.Parse(parameters[4]); var officeId = int.Parse(parameters[5]); var car = new Car() { Make = make, Model = model, Type = type, Price = price, OfficeId = officeId }; context.Cars.Add(car); context.SaveChanges(); return($"Car with ID {this.context.Cars.Count()} was created."); }
public string Execute(IList <string> parameters) { var car = orderComposer.SelectedCar; var user = orderComposer.SelectedUser; var departuredDate = orderComposer.DepartureDate; var arrivalDate = departuredDate.AddDays(orderComposer.Duration); car.OfficeId = orderComposer.DestinationOffice.Id; var order = new Order() { CarId = car.Id, UserId = user.Id, DepartureDate = departuredDate, ArrivalDate = arrivalDate }; context.Orders.Add(order); context.SaveChanges(); orderComposer.Finalize(); return($"Order with ID {this.context.Orders.Count()} was created."); }