예제 #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;
 }