public void AddMechanic(MechanicView mechanic) { Mechanics mechanics = mapper.Map <MechanicView, Mechanics>(mechanic); db.Mechanics.Add(mechanics); db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id,Name,Email,Phone,Make")] MechanicView mechanicview) { if (ModelState.IsValid) { _mechanicManager.UpdateMechanic(mechanicview); return(RedirectToAction("Index")); } return(View(mechanicview)); }
public void UpdateMechanic(MechanicView mechanics) { Mechanics mechanic = db.Mechanics.Find(mechanics.Id); mechanic.Name = mechanics.Name; mechanic.Email = mechanics.Email; mechanic.Phone = mechanics.Phone; mechanic.Make = mechanics.Make; db.Entry(mechanic).State = EntityState.Modified; }
public MechanicView GetMechanic(int?id) { Mechanics v = db.Mechanics.Find(id); if (v == null) { return(null); } MechanicView mechanic = mapper.Map <Mechanics, MechanicView>(v); return(mechanic); }
// GET: Mechanic/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MechanicView mechanic = _mechanicManager.GetMechanic(id); if (mechanic == null) { return(HttpNotFound()); } return(View(mechanic)); }
public void UpdateMechanic(MechanicView mechanic) { _mechanicRepository.UpdateMechanic(mechanic); }
public void AddMechanic(MechanicView mechanic) { _mechanicRepository.AddMechanic(mechanic); }