Example #1
0
        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("Текущая презентация является версией более чем одной презентации"));
            }

        }
Example #2
0
 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;
 }
Example #3
0
 public string SaveAdVersioningByEntity(Versioning versioning)
 {
     context.Entry<Versioning>(versioning).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
     return ResponseStatuses.SUCCESS;
 }