Beispiel #1
0
        /// <summary>
        /// 保存添加或编辑的广告位
        /// </summary>
        /// <param name="mallArtPosition"></param>
        /// <returns></returns>
        public string ArtPositionSave(MallArtPosition mallArtPosition)
        {
            Guid gId = mallArtPosition.Gid;
            //保存新添加的广告位
            if (gId.Equals(Guid.Empty) || gId.Equals(null))
            {
                string strCode = mallArtPosition.Code;
                bool flag = false;
                var ArtPositionList = (from o in dbEntity.MallArtPositions.Include("Name") where (o.OrgID == gOrgId) select o).ToList();
                foreach (var item in ArtPositionList)
                {
                    if (item.Code == strCode && item.Deleted == false)
                    {
                        flag = true;
                        return "error";
                    }
                    else if (item.Code == strCode && item.Deleted == true)
                    {
                        item.Deleted = false;
                        item.Name.SetResource(ModelEnum.ResourceType.STRING, mallArtPosition.Name);
                        item.OrgID = gOrgId;
                        item.Code = mallArtPosition.Code;
                        item.Width = mallArtPosition.Width;
                        item.Height = mallArtPosition.Height;
                        item.Matter = mallArtPosition.Matter;
                        item.Show = mallArtPosition.Show;
                        dbEntity.SaveChanges();
                        flag = true;
                        return "success";
                    }
                }
                if (flag == false)
                {
                    MallArtPosition oMallArtPosition = new MallArtPosition
                    {
                        Name = new GeneralResource(ModelEnum.ResourceType.STRING, mallArtPosition.Name)
                    };
                    oMallArtPosition.OrgID = gOrgId;
                    oMallArtPosition.Show = mallArtPosition.Show;
                    oMallArtPosition.Code = mallArtPosition.Code;
                    oMallArtPosition.Width = mallArtPosition.Width;
                    oMallArtPosition.Height = mallArtPosition.Height;
                    oMallArtPosition.Matter = mallArtPosition.Matter;
                    dbEntity.MallArtPositions.Add(oMallArtPosition);
                    dbEntity.SaveChanges();
                }
            }
            //保存编辑后的广告位
            else
            {
                MallArtPosition oMallArtPosition = (from o in dbEntity.MallArtPositions.Include("Name") where (o.Deleted == false && o.Gid == gId) select o).SingleOrDefault();
                if (oMallArtPosition != null)
                {
                    oMallArtPosition.Name.SetResource(ModelEnum.ResourceType.STRING, mallArtPosition.Name);
                    oMallArtPosition.OrgID = mallArtPosition.OrgID;
                    oMallArtPosition.Code = mallArtPosition.Code;
                    oMallArtPosition.Width = mallArtPosition.Width;
                    oMallArtPosition.Height = mallArtPosition.Height;
                    oMallArtPosition.Matter = mallArtPosition.Matter;
                    oMallArtPosition.Show = mallArtPosition.Show;
                    dbEntity.SaveChanges();

                }
            }

            return "success";
        }
Beispiel #2
0
 /// <summary>
 /// 添加或者编辑广告位
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult ArtPositionAddOrEdit(Guid? id)
 {
     MallArtPosition oMallArtPosition = new MallArtPosition();
     //添加新的广告位置
     if (id == null)
     {
         oMallArtPosition.Name = NewResource(ModelEnum.ResourceType.STRING,gOrgId);
         ViewBag.ShowList = SelectEnumList(oMallArtPosition.Show);
     }
     //编辑原有广告位置
     else
     {
         oMallArtPosition = (from o in dbEntity.MallArtPositions where(o.Gid==id&&o.Deleted ==false)select o).SingleOrDefault();
         if (oMallArtPosition != null)
         {
             oMallArtPosition.Name = RefreshResource(ModelEnum.ResourceType.STRING, oMallArtPosition.Name, gOrgId);
             ViewBag.ShowList = SelectEnumList(oMallArtPosition.Show);
         }
     }
     return View("ArtPositionAddOrEdit",oMallArtPosition);
 }