Beispiel #1
0
 public ActionResult Create(CityCateViewModel model)
 {
     ViewBag.Data_PID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             CityCate entity = new CityCate();
             entity.CateName = model.CateName;
             entity.PID = model.PID == 0 ? null : model.PID;
             entity.Level = model.Level;
             entity.OrderIndex = model.OrderIndex;
             entity.Code = model.Code;
             cityService.Create(entity);
             result.Message = "添加城市信息成功!";
             LogHelper.WriteLog("添加城市信息成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加城市信息错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Beispiel #2
0
 public void Update(CityCate model)
 {
     var target = Find(model.ID);
     db.Attach<CityCate>(target);
     target.CateName = model.CateName;
     target.PID = model.PID;
     target.Level = model.Level;
     target.Code = model.Code;
     target.OrderIndex = model.OrderIndex;
     db.Commit();
 }
Beispiel #3
0
 public void Delete(CityCate model)
 {
     var target = Find(model.ID);
     db.Remove<CityCate>(target);
     db.Commit();
 }
Beispiel #4
0
 public void Create(CityCate model)
 {
     db.Add<CityCate>(model);
     db.Commit();
 }
Beispiel #5
0
        private void GetPrevCityGroup(List<LinkGroup> result, CityCate city, QueryTerm queryTerm)
        {
            var pCity = CityCateService.GetALL().Single(x => x.ID == city.PID);

            LinkGroup cityGroup = new LinkGroup()
            {
                Group = new LinkItem()
                {
                    Name = !pCity.PID.HasValue ? "城市" : pCity.CateName,
                    Url = Url.Action("index", new
                    {
                        province = queryTerm.Province,
                        city = !pCity.PID.HasValue ? 0 : pCity.ID,
                        mediacode = queryTerm.MediaCode,
                        formatcode = queryTerm.FormatCode,
                        ownercode = queryTerm.OwnerCode,
                        periodcode = queryTerm.PeriodCode,
                        authstatus = queryTerm.AuthStatus,
                        deadline = queryTerm.DeadLine,
                        price = queryTerm.Price,
                        order = queryTerm.Order,
                        descending = queryTerm.Descending,
                        page = 1
                    })
                }
            };

            var cityList = CityCateService.GetALL()
               .Where(x => x.PID == pCity.ID).ToList();

            var citySelectList = cityList.Select(x => new LinkItem()
            {
                ID = x.ID,
                Name = x.CateName,
                Url = Url.Action("index", new
                {
                    province = queryTerm.Province,
                    city = x.ID,
                    mediacode = queryTerm.MediaCode,
                    formatcode = queryTerm.FormatCode,
                    ownercode = queryTerm.OwnerCode,
                    periodcode = queryTerm.PeriodCode,
                    authstatus = queryTerm.AuthStatus,
                    deadline = queryTerm.DeadLine,
                    price = queryTerm.Price,
                    order = queryTerm.Order,
                    descending = queryTerm.Descending,
                    page = 1
                })
            }).ToList();

            if (citySelectList.Any(x => x.ID == city.ID))
            {
                citySelectList.Single(x => x.ID == city.ID).Selected = true;
            }

            cityGroup.Items = citySelectList;

            result.Add(cityGroup);

            if (pCity.PID.HasValue)
            {
                GetPrevCityGroup(result, pCity, queryTerm);
            }
        }
Beispiel #6
0
        private void GetNextCityGroup(List<LinkGroup> result, CityCate city, QueryTerm queryTerm)
        {
            if (CityCateService.GetALL().Any(x => x.PID == city.ID))
            {
                LinkGroup cityGroup = new LinkGroup()
                {
                    Group = new LinkItem()
                    {
                        Name = city.CateName,
                        Url = Url.Action("index", new
                        {
                            province = queryTerm.Province,
                            city = city.ID,
                            mediacode = queryTerm.MediaCode,
                            formatcode = queryTerm.FormatCode,
                            ownercode = queryTerm.OwnerCode,
                            periodcode = queryTerm.PeriodCode,
                            authstatus = queryTerm.AuthStatus,
                            deadline = queryTerm.DeadLine,
                            price = queryTerm.Price,
                            order = queryTerm.Order,
                            descending = queryTerm.Descending,
                            page = 1
                        })
                    }
                };

                var cityList = CityCateService.GetALL()
                   .Where(x => x.PID == city.ID).ToList();

                var citySelectList = cityList.Select(x => new LinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = queryTerm.Province,
                        city = x.ID,
                        mediacode = queryTerm.MediaCode,
                        formatcode = queryTerm.FormatCode,
                        ownercode = queryTerm.OwnerCode,
                        periodcode = queryTerm.PeriodCode,
                        authstatus = queryTerm.AuthStatus,
                        deadline = queryTerm.DeadLine,
                        price = queryTerm.Price,
                        order = queryTerm.Order,
                        descending = queryTerm.Descending,
                        page = 1
                    })
                }).ToList();

                cityGroup.Items = citySelectList;

                result.Add(cityGroup);
            }
        }