private static void addNewCar() { try { string Type, Color; decimal Price; Console.Write("\t Write Type Car:"); Type = Console.ReadLine(); Console.Write("\t Write Collor Car:"); Color = Console.ReadLine(); bool pr = false; do { Console.Write("\t Write Price Car:"); pr = decimal.TryParse(Console.ReadLine(), out Price); if (Price <= 0) { pr = false; } } while (!pr); CarLogic.AddCar(new Car(Type, Color, Price)); Console.WriteLine("\tSuccessfully"); } catch (Exception e) { Console.WriteLine("\tError. Something went wrong!)", e.Message); } }
public void AddCarService(string registrationNumber, string brand, string model, int year) { if (registrationNumber == null || brand == null || model == null || year == 0) { throw new FaultException("Yours input are not correct, please try again"); } _car.AddCar(registrationNumber, brand, model, year); }
public ActionResult AddCar(HttpPostedFileBase CarImage, CarIndexViewsModel vm, int dropdownlistCarsModels, int CompanyId, string Licence_Plate, int Mileage, string Energy) { CarDTO car = new CarDTO { Energy_Value = Energy, id_Car_Model = dropdownlistCarsModels, is_Active = 1, is_Available = 1, Licence_Plate = Licence_Plate, Mileage = Mileage, Id_User = (int)Session["userId"], Id_Company = CompanyId }; if (CarImage != null && CarImage.ContentLength > 0) { try { string extension = Path.GetExtension(CarImage.FileName); string filename = Licence_Plate; string newFile = filename + extension; string path = Path.Combine(Server.MapPath("~/Images/Cars"), newFile); CarImage.SaveAs(path); } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } carLogic.AddCar(car); return(RedirectToAction("Index")); }
static void AddCarList() { CarLogic.AddCar(new Car("Vaz", "Red", 0)); CarLogic.AddCar(new Car("Vaz", "Green", 0)); CarLogic.AddCar(new Car("Vaz", "Black", 0)); }