public void Add(SupportORAgainst entity)
        {
            if (entity.BookInfo != null)
            {
                entity.BookInfo = this.DataSource.BookInfos.FirstOrDefault(b => b.ID == entity.BookInfo.ID);
            }

            if (entity.UserInfo != null)
            {
                entity.UserInfo = this.DataSource.UserInfos.FirstOrDefault(u => u.ID == entity.UserInfo.ID);
            }

            this.DataSource.SupportORAgainstInfos.Add(entity);
            this.DataSource.SaveChanges();
        }
Ejemplo n.º 2
0
        public bool SupportORAgainstBook(string q, bool flag)
        {
            try
            {
                SupportORAgainst readyToAdd = new SupportORAgainst();
                if (flag)
                {
                    readyToAdd.Status = SupportAgainstStatus.Support;
                }
                else
                {
                    readyToAdd.Status = SupportAgainstStatus.Against;
                }
                readyToAdd.UserInfo = this.LoginUser();
                readyToAdd.BookInfo = this.IBookInfoDataProvider.GetBookInfoByID(Convert.ToInt32(q));
                this.ISupportORAgainstInfoDataProvider.Add(readyToAdd);
            }
            catch(Exception ex)
            {
                return false;
            }

            return true;
        }
 public void Update(SupportORAgainst supportORAgainst)
 {
     this.DataSource.SaveChanges();
 }