public MakeViewModel(MakeDto makeDto) { Id = makeDto.Id; Name = makeDto.Name; Description = makeDto.Description; Country = makeDto.Country; }
public ActionResult Edit(MakeViewModel makeVM) { try { if (ModelState.IsValid) { using (MakeServiceReference.MakeClient service = new MakeServiceReference.MakeClient()) { MakeDto makeDto = new MakeDto { Id = makeVM.Id, Name = makeVM.Name, Description = makeVM.Description, Country = makeVM.Country }; service.PostMake(makeDto); } return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
public bool Save(MakeDto makeDto) { Make make = new Make { Id = makeDto.Id, // !NBBBB Name = makeDto.Name, Description = makeDto.Description, Country = makeDto.Country }; try { using (UnitOfWork unitOfWork = new UnitOfWork()) { if (makeDto.Id == 0) { unitOfWork.MakeRepository.Insert(make); } else { unitOfWork.MakeRepository.Update(make); } unitOfWork.Save(); } return(true); } catch { Console.WriteLine(make); return(false); } }
public string PutMake(MakeDto makeDto) { if (!_context.Save(makeDto)) { return("Make is not updated."); } return("Make is updated."); }
public string PostMake(MakeDto makeDto) { if (!_context.Save(makeDto)) { return("Make is not inserted."); } return("Make is inserted."); }
public MakeDto GetById(int id) { MakeDto makeDto = new MakeDto(); using (UnitOfWork unitOfWork = new UnitOfWork()) { Make make = unitOfWork.MakeRepository.GetByID(id); if (make != null) { makeDto = new MakeDto { Id = make.Id, Name = make.Name, Description = make.Description, Country = make.Country }; } } return(makeDto); }