public CollegeRegion Get(int id, double area, string message)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(null);
            }
            UpdateRegion(id, area, message, info, RegionType.Polygon);
            _repository.Update(info);
            return(info.CollegeRegion);
        }
Exemple #2
0
        public CollegeDto GetCollege(int collegeId)
        {
            var college = _collegeCache.Get(collegeId);

            _collegeRepository.Update(collegeId, (x) => {
                x.Hits += 1;
            });
            return(college);
        }
Exemple #3
0
 public ActionResult Edit(College college)
 {
     try
     {
         var        get           = _universityRepository.GetAll();
         SelectList lstUniversity = new SelectList(get, "id", "Name");
         ViewBag.University = lstUniversity;
         _collegeRepository.Update(college);
         _collegeRepository.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #4
0
 public Tuple <bool, string> AddOrUpdateCollege(College college, StateOperation stateOperation)
 {
     try
     {
         if (stateOperation == StateOperation.درج)
         {
             _collegeRepository.Add(college);
         }
         else
         {
             _collegeRepository.Update(college);
         }
         _unitOfWork.SaveChanges();
         return(new Tuple <bool, string>(true, "عملیات ثبت شد"));
     }
     catch (Exception)
     {
         return(new Tuple <bool, string>(false, "خطا در انجام عملیات"));
     }
 }
        public ActionResult CollgeEdit(CollegeEditViewModel viewModel)
        {
            Town town = _townRepository.GetAll().FirstOrDefault(x =>
                                                                x.CityName == viewModel.CollegeDto.CityName &&
                                                                x.DistrictName == viewModel.CollegeDto.DistrictName &&
                                                                x.TownName == viewModel.CollegeDto.TownName);
            int townId = town == null ? -1 : town.Id;

            CollegeInfo info = viewModel.CollegeDto.Id == -1
                ? new CollegeInfo()
                : _repository.Get(viewModel.CollegeDto.Id);

            if (info == null)
            {
                TempData["error"] = "该校园不存在。无法修改!";
                return(RedirectToAction("List"));
            }
            int    oldTownId = info.TownId;
            string oldName   = info.Name;

            viewModel.CollegeDto.CloneProperties(info);
            info.TownId = townId;
            if (viewModel.CollegeDto.Id == -1)
            {
                _repository.Insert(info);
                TempData["success"] = "新增校园" + info.Name + "信息成功!";
            }
            else
            {
                info.TownId         = oldTownId;
                info.Name           = oldName;
                TempData["success"] = "修改校园" + info.Name + "信息成功!";
                _repository.Update(info);
            }
            return(RedirectToAction("List"));
        }
Exemple #6
0
 public int UpdateCollege(BLModel.College college)
 {
     return(_collegeRepository.Update((DLModel.College) new DLModel.College().InjectFrom(college)));
 }
Exemple #7
0
 public College Update(College college)
 {
     return(_collegeRepository.Update(college));
 }