예제 #1
0
        /// <summary>
        /// 设置当前登录人的信息
        /// 设置元数据的数据库的实例
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //设置元数据的数据库的实例
            Dal = CommonClass.SetMetadataDal();
        }
        public int Create(DalCollection entity)
        {
            var obj = entity.ToOrmCollection();

            context.Collections.Add(obj);
            context.SaveChanges();
            return(obj.CollectionID);
        }
        public void Delete(DalCollection entity)
        {
            var cl = context.Collections.FirstOrDefault(e => e.CollectionID == entity.ID);

            if (cl != null)
            {
                context.Collections.Remove(cl);
            }
        }
        public void MoveBook(DalCollectionBook book, DalCollection collection)
        {
            var dbBook = context.Collection_Book.FirstOrDefault(e => e.Collection_BookID == book.ID);

            if (dbBook != null)
            {
                book.CollectionID = collection.ID;
            }
        }
 public static ServiceCollection ToServiceCollection(this DalCollection cl)
 {
     return(new ServiceCollection
     {
         ID = cl.ID,
         Name = cl.Name,
         Description = cl.Description,
         UserID = cl.UserID
     });
 }
예제 #6
0
 public static Collections ToOrmCollection(this DalCollection cl)
 {
     return(new Collections
     {
         CollectionID = cl.ID,
         Name = cl.Name,
         Description = cl.Description,
         UserID = cl.UserID
     });
 }
        public void Update(DalCollection entity)
        {
            var a = context.Collections.FirstOrDefault(e => e.CollectionID == entity.ID);

            if (a != null)
            {
                a.Description = entity.Description;
                a.Name        = entity.Name;
            }
        }
        public void AddBook(DalCollection collection, DalBook book)
        {
            var dbBook = context.Books.FirstOrDefault(e => e.BookID == book.ID);
            var dbCl   = context.Collections.FirstOrDefault(e => e.CollectionID == collection.ID);

            if (dbBook != null && dbCl != null)
            {
                Collection_Book cb = new Collection_Book
                {
                    IsRead       = null,
                    BookID       = dbBook.BookID,
                    CollectionID = dbCl.CollectionID
                };
                context.Collection_Book.Add(cb);
            }
        }
예제 #9
0
        public IEnumerable <ServiceCollection> GetUserCollections(ServiceUser user)
        {
            var collections = unit.Collections.GetUserCollections(user.ToDalUser()).Select(e => e.ToServiceCollection());

            if (!collections.Any())
            {
                DalCollection cl = new DalCollection()
                {
                    Name        = "Favorite",
                    Description = "There is all you favorite books.",
                    UserID      = user.ID
                };
                unit.Collections.AddUserCollection(cl);
                unit.Save();
            }
            return(unit.Collections.GetUserCollections(user.ToDalUser()).Select(e => e.ToServiceCollection()));
        }
예제 #10
0
        public void LoadData()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.Ashx.BaseAshx]判断Url参数"
            };

            DalCollection dalCollection = DalCollection;

            dalCollection.DalMetadata = DalCollection.DalCustomer;

            var managerFormMeta = new ManagerFormMeta
            {
                DalCollection = dalCollection,
                PageViewID    = int.Parse(PageViewID)
            };

            DicFormInfo = managerFormMeta.GetMetaData(debugInfo.DetailList);

            if (DicFormInfo == null)
            {
                return;
            }

            foreach (KeyValuePair <int, IColumn> info in DicFormInfo)
            {
                var bInfo = (ColumnMeta)info.Value;

                //修改类型,把数据库字段类型,变成.net类型
                switch (bInfo.ColType)
                {
                case "nvarchar":
                case "varchar":
                case "nchar":
                case "char":
                case "text":
                case "ntext":
                case "uniqueidentifier":
                    bInfo.PropertyType = "string";
                    break;

                case "bigint":
                    bInfo.PropertyType = "Int64";
                    break;

                case "int":
                    bInfo.PropertyType = "Int32";
                    break;

                case "smallint":
                case "tinyint":
                    bInfo.PropertyType = "Int16";
                    break;

                case "datetime":
                case "smalldatetime":
                    bInfo.PropertyType = "DateTime";
                    break;

                case "bit":
                    bInfo.PropertyType = "bool";
                    break;


                case "money":
                case "smallmoney":
                    bInfo.PropertyType = "decimal";
                    break;

                default:
                    bInfo.PropertyType = bInfo.ColType;
                    break;
                }
            }

            debugInfo.Stop();
        }
 public void AddUserCollection(DalCollection collection)
 {
     context.Collections.Add(collection.ToOrmCollection());
 }
 public IEnumerable <DalCollectionBook> GetCollectionBooks(DalCollection collection)
 {
     return
         (context.Collection_Book.Where(e => e.CollectionID == collection.ID).ToList().Select(e => e.ToDalCollectionBook()));
 }
 public IEnumerable <DalBook> GetCollcetionBooks(DalCollection collection)
 {
     return(context.Collections.FirstOrDefault(e => e.CollectionID == collection.ID)?
            .Collection_Book.Select(e => e.Books.ToDalBook()));
 }