示例#1
0
 public void Update(OutDoor model)
 {
     var target = Find(model.ID);
     db.Attach<OutDoor>(target);
     target.Name = model.Name;
     db.Commit();
 }
示例#2
0
        public OutDoor Create(OutDoorAdminViewModel model)
        {
            OutDoor od = new OutDoor();
            od.AddIP = HttpHelper.IP;
            od.AddTime = DateTime.Now;
            od.CityCodeValue = model.CityCode;
            od.CityCode = Utilities.GetCascadingId(model.CityCode);
            if (string.IsNullOrEmpty(model.Description))
            {
                od.Description = string.Empty;
            }
            else
            {
                od.Description = model.Description;
            }
            od.FormatCode = model.FormatCode;
            od.HasLight = model.HasLight;
            od.LastIP = HttpHelper.IP;
            od.LastTime = DateTime.Now;
            od.Lat = Convert.ToDouble(model.Position.Split('|')[0]);
            od.Lng = Convert.ToDouble(model.Position.Split('|')[1]);
            od.Location = model.Location;
            od.MemberID = model.MemberID;
            od.MediaCodeValue = model.MediaCode;
            od.MediaCode = Utilities.GetCascadingId(model.MediaCode);
            od.Name = model.Name;
            //od.PeriodCode = model.PeriodCode;
            od.PeriodCode = 3;
            od.Price = model.Price;
            od.RealPrice = model.RealPrice;
            //od.PriceExten = model.PriceExten;

            od.TrafficAuto = model.TrafficAuto;
            od.TrafficPerson = model.TrafficPerson;
            od.VideoUrl = model.VideoUrl;
            od.Unapprovedlog = string.Empty;

            //MediaArea参数设置
            if (!string.IsNullOrEmpty(model.MediaArea))
            {
                var areaParams = model.MediaArea.Split('|');
                var IsRegular = Convert.ToBoolean(areaParams[0]);
                if (IsRegular)
                {
                    od.IsRegular = true;
                    od.Wdith = Convert.ToDecimal(areaParams[1]);
                    od.Height = Convert.ToDecimal(areaParams[2]);
                    od.TotalFaces = Convert.ToInt32(areaParams[3]);
                    od.TotalArea = od.Wdith * od.Height * od.TotalFaces;
                }
                else
                {
                    od.IsRegular = false;
                    od.IrRegularArea = model.MediaArea;
                    od.TotalArea = 0;
                    for (var i = 1; i < areaParams.Length; i += 2)
                    {
                        od.TotalArea += (Convert.ToDecimal(areaParams[i]) * Convert.ToDecimal(areaParams[i + 1]));
                    }
                    od.TotalFaces = areaParams.Length / 2;
                }
            }
            //Light Time 设置
            if (model.HasLight)
            {
                if (!string.IsNullOrEmpty(model.LightTime) && model.LightTime.Split('|').Length == 2)
                {
                    var LightTime = model.LightTime.Split('|');
                    od.LightStart = Convert.ToInt32(LightTime[0]);
                    od.LightEnd = Convert.ToInt32(LightTime[1]);
                }
            }

            //MediaImg 设置
            od.MediaImg = model.MediaImg;
            od.MediaFoucsImg = UIHelper.GetImgUrl(model.MediaImg.Split(',')[0], ImgUrlType.Img120);

            //补充信息设置
            //if (!string.IsNullOrEmpty(model.AreaCate))
            //{
            //    var AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var AreaCateList = AreaCateService.GetALL().Where(x => AreaCateArray.Contains(x.ID));
            //    od.AreaCate.AddRange(AreaCateList);
            //}

            //if (!string.IsNullOrEmpty(model.IndustryCate))
            //{
            //    var IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var IndustryCateList = IndustryCateService.GetALL().Where(x => IndustryCateArray.Contains(x.ID));
            //    od.IndustryCate.AddRange(IndustryCateList);
            //}

            //if (!string.IsNullOrEmpty(model.CrowdCate))
            //{
            //    var CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var CrowdCateList = CrowdCateService.GetALL().Where(x => CrowdCateArray.Contains(x.ID));
            //    od.CrowdCate.AddRange(CrowdCateList);
            //}

            //if (!string.IsNullOrEmpty(model.PurposeCate))
            //{
            //    var PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            //    var PurposeCateList = PurposeCateService.GetALL().Where(x => PurposeCateArray.Contains(x.ID));
            //    od.PurposeCate.AddRange(PurposeCateList);
            //}

            //认证信息设置
            //od.OwnerCode = model.OwnerCode;
            //if (!string.IsNullOrEmpty(model.CredentialsImg))
            //{
            //    od.CredentialsImg = model.CredentialsImg;
            //}

            //od.OwnerCode = model.OwnerCode;
            od.Deadline = model.Deadline;

            //set OutDoor Status 待审核状态
            od.Status = (int)OutDoorStatus.PreVerify;

            db.Add<OutDoor>(od);
            db.Commit();
            return od;
        }
示例#3
0
 public void Delete(OutDoor model)
 {
     var target = Find(model.ID);
     db.Remove<OutDoor>(target);
     db.Commit();
 }
示例#4
0
 public void Create(OutDoor model)
 {
     db.Add<OutDoor>(model);
     db.Commit();
 }