示例#1
0
文件: DbHelper.cs 项目: macki/razem
        public bool AddDealsToMainList(DealModels deal)
        {
            try
            {
                deal.AddedDate = DateTime.Now;
                dbStore.Entry(deal).State = EntityState.Modified;
                dbStore.Deal.Add(deal);
                dbStore.SaveChanges();
                dbStore = new RazemTaniejEntities();
                return true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return false;
        }
示例#2
0
文件: DbHelper.cs 项目: macki/razem
        public void EditUser(UserModels newUser)
        {
            var user = GetUser(newUser.UserId);

            user.Name = newUser.Name;
            user.Gender = newUser.Gender;
            user.Email = newUser.Email;
            user.Experiance = newUser.Experiance;
            user.numberOfPosts = newUser.numberOfPosts;
            user.SignedDate = newUser.SignedDate;
            user.Validated = newUser.Validated;
            user.ValidationUrl = newUser.ValidationUrl;

            dbStore.Entry(user).State = System.Data.EntityState.Modified;
            dbStore.SaveChanges();
            dbStore = new RazemTaniejEntities();
        }
示例#3
0
文件: DbHelper.cs 项目: macki/razem
 public void CreateNewComment(CommentModels newComment, int _dealId, string userName)
 {
     newComment.Data = DateTime.Now;
     newComment.Deal = GetDeal(_dealId);
     IncrementDealComments(newComment.Deal);
     newComment.User = GetUser(userName);
     DataBase.Comment.Add(newComment);
     DataBase.SaveChanges();
     dbStore = new RazemTaniejEntities();
 }
示例#4
0
文件: DbHelper.cs 项目: macki/razem
        public void EditComment(CommentModels newComment)
        {
            var comment = (from c in dbStore.Comment
                           where c.CommentsModelsId == newComment.CommentsModelsId
                           select c).Single();

            comment.Content = newComment.Content;
            comment.Title = newComment.Title;
            comment.Rank = newComment.Rank;
            comment.Data = newComment.Data;

            dbStore.Entry(comment).State = System.Data.EntityState.Modified;
            dbStore.SaveChanges();
            dbStore = new RazemTaniejEntities();
        }
示例#5
0
文件: DbHelper.cs 项目: macki/razem
        public void CheckExpiredDeal()
        {
            var deals = GetAllDeals();

            foreach (var d in deals)
            {
                if (d.EndDate < DateTime.Now)
                {
                    d.Expired = true;
                }
            }

            dbStore.SaveChange();
            dbStore = new RazemTaniejEntities();
        }