Пример #1
0
        public ActionResult DeleteLocation(int id)
        {
            var locationModelFromRepo = _repository.GetLocationById(id);

            if (locationModelFromRepo == null)
            {
                return(NotFound());
            }
            //don't delete office location if there are employees there
            if (locationModelFromRepo.Employees.Count > 0)
            {
                return(Json(new { error = "Cannot remove office locations with employees" }));
            }
            _repository.DeleteLocation(locationModelFromRepo);
            _repository.SaveChanges();
            return(NoContent());
        }
 /// <summary>
 /// Save changes to repository
 /// </summary>
 public void SaveChanges()
 {
     repo.SaveChanges();
 }