public LocationDTO AddLocation(LocationDTO local) { var temp = Mapper.Map<Location>(local); uOW.LocationRepo.Insert(temp); uOW.Save(); return Mapper.Map<LocationDTO>(temp); }
public LocationDTO UpdateLocation(LocationDTO local) { var temp = uOW.LocationRepo.Get(u => u.UserId == local.UserId).FirstOrDefault(); if (temp == null) { return null; } uOW.LocationRepo.SetStateModified(temp); temp.DistrictId = local.DistrictId; uOW.Save(); return Mapper.Map<LocationDTO>(temp); }
public ActionResult EditLocation(int Id) { var user = Session["User"] as Model.DTO.UserDTO; if (user == null) { return RedirectToRoute(new { controller = "Home", action = "Index" }); } LocationDTO local = locationmanager.GetByUserId(user.Id); if (local != null) { local.DistrictId = Id; locationmanager.UpdateLocation(local); return RedirectToAction("Index", "Driver"); } else { LocationDTO district = new LocationDTO() { UserId = user.Id, DistrictId = Id }; locationmanager.AddLocation(district); return RedirectToAction("Index", "Driver"); } }