コード例 #1
0
        public void AddNewVote(ClassificationModel Classification)
        {
            if (Classification == null)
            {
                throw new NullReferenceException();
            }

            if (Classification.Point != null)
            {
                int value = GetClassificationForPoint(Classification.Point).Where(x => x.User.Id == Classification.User.Id).Count();

                if (value > 0)
                {
                    return;
                }
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                CLASSIFICATION _new = new CLASSIFICATION
                {
                    ID              = (Classification.Id == null || Classification.Id == Guid.Empty ? Guid.NewGuid() : Classification.Id),
                    EVENT           = (Classification.Event != null ? data.EVENT.SingleOrDefault(x => x.ID.Equals(Classification.Event.Id)) : null),
                    POINT           = (Classification.Point != null ? data.POINT.SingleOrDefault(x => x.ID.Equals(Classification.Point.Id)) : null),
                    CLASSIFICATION1 = Classification.Classification,
                    USER            = data.USER.SingleOrDefault(x => x.ID.Equals(Classification.User.Id)),
                    CREATION_DATE   = DateTime.Now
                };

                data.CLASSIFICATION.AddObject(_new);
                data.SaveChanges();
            }
        }
コード例 #2
0
 public void Add(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         db.CLASSIFICATIONs.Add(classiObj);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public void Delete(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         CLASSIFICATION csignID = db.CLASSIFICATIONs.Find(classiObj.SignId);
         db.CLASSIFICATIONs.Remove(csignID);
         db.SaveChanges();
     }
 }
コード例 #4
0
 public void Update(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         db.CLASSIFICATIONs.Attach(classiObj);
         db.Entry(classiObj).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public bool DoesClassificationContainBooks(CLASSIFICATION classification)
 {
     using (DbLibrary db = new DbLibrary())
     {
         try
         {
             return(db.CLASSIFICATIONs.Find(classification.SignId).BOOKs.ToList().Count() > 0);
         }
         catch
         {
             return(false);
         }
     }
 }
 public bool CreateClassification(CLASSIFICATION eClassification)
 {
     using (DbLibrary db = new DbLibrary())
     {
         try
         {
             eClassification.SignId = GetNewID();
             db.CLASSIFICATIONs.Add(eClassification);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
 public bool EditClassification(CLASSIFICATION eClassification)
 {
     using (DbLibrary db = new DbLibrary())
     {
         try
         {
             CLASSIFICATION classification = db.CLASSIFICATIONs.FirstOrDefault(x => x.SignId.Equals(eClassification.SignId));
             db.Entry(classification).CurrentValues.SetValues(eClassification);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
 public bool DeleteClassification(CLASSIFICATION eClassification)
 {
     using (DbLibrary db = new DbLibrary())
     {
         try
         {
             var classification = db.CLASSIFICATIONs.Include(a => a.BOOKs).FirstOrDefault(a => a.SignId == eClassification.SignId);
             classification.BOOKs.Clear();
             db.CLASSIFICATIONs.Remove(classification);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }