示例#1
0
文件: Service1.cs 项目: tcns/impulse
        public string SaveAdVersioningByIds(int rootId, int childId)
        {
            Versioning versioning = null;
            try
            {
                versioning = context.Versioning.Single(a => a.RootAdId == rootId && a.ChildAdId == childId);
            }
            catch (Exception ex)
            { }
            if (versioning == null)
            {
                versioning = new Versioning();
                versioning.RootAdId = rootId;
                versioning.ChildAdId = childId;
                context.Versioning.Add(versioning);
                context.SaveChanges();
                return ResponseStatuses.SUCCESS;
            }
            else
            {
                throw new FaultException<VersioningException>(new VersioningException("Текущая презентация является версией более чем одной презентации"));
            }

        }
示例#2
0
文件: Service1.cs 项目: tcns/impulse
 public string SaveAdVersioningByPreviousIdAndUrl(int prevId, string childUrl)
 {
     int childId = context.SimpleAds.FirstOrDefault(a => a.ShortUrlKey.Equals(childUrl)).Id;
     var rootVersion = context.Versioning.FirstOrDefault(a => a.ChildAdId == prevId);
     int rootId = prevId;
     if (rootVersion != null)
     {
         rootId = rootVersion.Id;
     }
     var versioning = new Versioning();
     versioning.RootAdId = rootId;
     versioning.ChildAdId = childId;
     context.Versioning.Add(versioning);
     context.SaveChanges();
     return ResponseStatuses.SUCCESS;
 }
示例#3
0
文件: Service1.cs 项目: tcns/impulse
 public string SaveAdVersioningByEntity(Versioning versioning)
 {
     context.Entry<Versioning>(versioning).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
     return ResponseStatuses.SUCCESS;
 }