public bool Update(CarDTO item) { var car = entities.Cars.FirstOrDefault(s => s.Id == item.Id); if(car!=null) { car.brand = item.brand; car.colour = item.colour; car.isEfficient = item.isEfficient; car.model = item.model; car.price = item.price; car.productionDate = item.productionDate; car.stationId = item.stationId; entities.SaveChanges(); return true; } return false; }
public async Task<bool> Put(CarDTO item) { return await this.Put<CarDTO, bool>("PUT", item); }
public async Task<bool> Post(CarDTO item) { return await this.Post<CarDTO, bool>("POST", item); }
private async void GetStations(CarDTO c) { var service = new StationDTOService(w.login,w.password); var stationss = await service.Get(); var stations = stationss.AsEnumerable(); StationsCollection = ToObservableCollectioncs.ToObservableCollection<StationDTO>(stations); var single = await service.Get(c.stationId); Station = single; }
public CarEditViewModel(CarDTO c,WorkerDTO w) { this.w = w; GetStations(c); Brand = c.brand; Model = c.model; Colour = c.colour; ProductionDate = c.productionDate; Price = c.price; IsEfficient = c.isEfficient; Id = c.Id; }
public void Add(CarDTO item) { entities.Cars.Add(Mapper.Map<Car>(item)); entities.SaveChanges(); }
public CarDetailViewModel(CarDTO c) { car = c; frenchCar = FrenchApi.GetCarById(c.frenchId); }
public string EditCar(CarDTO objTodo) { string msg; try { if (ModelState.IsValid) { var mod = FrenchApi.GetCarByBrandAndModel(objTodo.brand, objTodo.model); var stations = Task.Run((() => _stationjDtoService.Get())).Result; var station = stations.FirstOrDefault(s => objTodo.stationName.Contains(s.city)); if (station!=null && mod!=null) { objTodo.stationId = station.Id; objTodo.frenchId = mod.recordid; } var carput = Task.Run((() => _carDtoService.Put(objTodo))).Result; if(carput) msg = Messages.SuccessAdd; else { msg = Messages.UnexcpectedError; } } else { msg = Messages.ValidationFail; } } catch (Exception ex) { msg = Messages.ErrorOccured + ex.Message; } return msg; }
public CarDetailView(CarDTO car) { InitializeComponent(); this.DataContext = new CarDetailViewModel(car); }
public CarEditView(CarDTO c,WorkerDTO w) { InitializeComponent(); DataContext = new CarEditViewModel(c,w); }
private async void Accept() { Validate(); if (validationErrors.Count == 0) { var c = new CarDTO(); c.stationId = Station.Id; c.brand = SelectedBrand; c.colour = Colour; c.isEfficient = IsEfficient; c.model = Model; c.price = Price; c.productionDate = ProductionDate; c.frenchId = SelectedModel.recordid; var service = new CarDTOService(w.login, w.password); await service.Post(c); var msg = new FireRefresh(); Messenger.Default.Send<FireRefresh>(msg); Exit(); } }