コード例 #1
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
 public static DoResult <UserInfo> GetUserByEmail(GiaSinhVienEntities db, string email)
 {
     return(DAOCore.Do <UserInfo>(c =>
     {
         var userTemp = db.UserInfoes.FirstOrDefault(f => f.Email == email);
         return userTemp;
     }));
 }
コード例 #2
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
        public static DoResult ChangeStatus(GiaSinhVienEntities db, long id, UserStatus newStatus)
        {
            return(DAOCore.Do(c =>
            {
                var it = db.UserInfoes.Single(x => x.Id == id);

                it.Status = newStatus;
                db.SaveChanges();
            }));
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: GSVien/Code
            protected BaseController(GiaSinhVienEntities db = null)
            {
                _cacheListAction = new Dictionary <long, long[]>();

                if (db == null)
                {
                    Db = new GiaSinhVienEntities();
                }
                else
                {
                    Db = db;
                }
            }
コード例 #4
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
        public static DoResult <UserInfo> Update(GiaSinhVienEntities db, UserInfo data)
        {
            return(DAOCore.Do <UserInfo>(c =>
            {
                var it = db.UserInfoes.Single(x => x.Id == data.Id);
                it.UserName = data.UserName;
                it.Phone = data.Phone;
                it.Address = data.Address;
                it.AvatarPhoto = data.AvatarPhoto;
                it.Email = data.Email;
                it.GroupId = data.GroupId;

                db.SaveChanges();

                return it;
            }));
        }
コード例 #5
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
        public static DoResult <UserInfo> Insert(GiaSinhVienEntities db, UserInfo data)
        {
            return(DAOCore.Do <UserInfo>(c =>
            {
                var it = new UserInfo();
                it.Passwork = data.Passwork;
                it.UserName = data.UserName;
                it.Phone = data.Phone;
                it.Address = data.Address;
                it.AvatarPhoto = data.AvatarPhoto;
                it.Email = data.Email;
                it.GroupId = data.GroupId;
                it.CreateDate = DateTime.Now;
                it.Status = UserStatus.Active;

                db.UserInfoes.Add(it);
                db.SaveChanges();

                return it;
            }));
        }
コード例 #6
0
ファイル: Do.cs プロジェクト: GSVien/Code
        internal static DoResult Do(Action <DoController> action, GiaSinhVienEntities db = null)
        {
            var controller = new DoController(db);

            try
            {
                if (db == null)
                {
                    controller.Db.Database.Connection.Open();
                }
                action(controller);
            }
            catch (Exception ex)
            {
                controller.SetError(ex.Message, -1);
            }
            finally
            {
                controller.Db.Database.Connection.Close();
            }

            return(controller.Result);
        }
コード例 #7
0
ファイル: Do.cs プロジェクト: GSVien/Code
        internal static DoResult <T> Do <T>(Func <DoController <T>, T> action, GiaSinhVienEntities db = null)
        {
            var controller = new DoController <T>(db);

            try
            {
                if (db == null)
                {
                    controller.Db.Database.Connection.Open();
                }
                controller.Result.Result = action(controller);
            }
            catch (Exception ex)
            {
                controller.Result.Result = controller.FailResult;
                controller.SetError(ex.Message, -1);
            }
            finally
            {
                controller.Db.Database.Connection.Close();
            }

            return(controller.Result);
        }
コード例 #8
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
        public static PageResult <UserInfoModel> Get(
            GiaSinhVienEntities db,
            PageArg <UserInfoModel.Select, UserInfoModel.Sort> pageArg,
            long[] id               = null,
            StringParam str_Name    = null,
            NumericParam num_Status = null)
        {
            return(DAOCore.DoPage <UserInfoModel, UserInfoModel.Select, UserInfoModel.Sort>(pageArg, (c, p) =>
            {
                var total = new ObjectParameter("Total", typeof(int));
                var query = new ObjectParameter("Query", typeof(string));

                string data = null;

                //db.usp_Badwords_Get(
                //    pageArg.SelectQuery(), pageArg.SortQuery(), p.PageIndex, p.PageSize, pageArg.DebugQuery,
                //    id == null ? null : string.Join(",", id),
                //    str_Value == null ? null : str_Value.ToString(),
                //    num_Status == null ? null : num_Status.ToString(),
                //    total, query).FirstOrDefault();

                c.SetResult(p, c.ConvertFromXml(data), (int)total.Value, query.Value == DBNull.Value ? null : (string)query.Value);
            }));
        }
コード例 #9
0
        public static PageResult <ProductModel> Get(
            GiaSinhVienEntities db,
            PageArg <ProductModel.Select, ProductModel.Sort> pageArg,
            long[] id                      = null,
            StringParam str_Name           = null,
            NumericParam num_CategoryId    = null,
            NumericParam num_SubCategoryId = null,
            NumericParam num_Price         = null,
            NumericParam num_Status        = null,
            DateTimeParam date_CreateDate  = null,
            NumericParam num_PostUserId    = null,
            NumericParam num_DictrictId    = null,
            NumericParam num_ProviceId     = null)
        {
            return(DAOCore.DoPage <ProductModel, ProductModel.Select, ProductModel.Sort>(pageArg, (c, p) =>
            {
                var total = new ObjectParameter("Total", typeof(int));
                var query = new ObjectParameter("Query", typeof(string));

                var data = db.usp_Product_Get(
                    pageArg.SelectQuery(), pageArg.SortQuery(), p.PageIndex, p.PageSize, pageArg.DebugQuery,
                    id == null ? null : string.Join(",", id),
                    str_Name == null ? null : str_Name.ToString(),
                    num_CategoryId == null ? null : num_CategoryId.ToString(),
                    num_SubCategoryId == null ? null : num_SubCategoryId.ToString(),
                    num_Price == null ? null : num_Price.ToString(),
                    num_Status == null ? null : num_Status.ToString(),
                    date_CreateDate == null ? null : date_CreateDate.ToString(),
                    num_PostUserId == null ? null : num_PostUserId.ToString(),
                    num_DictrictId == null ? null : num_DictrictId.ToString(),
                    num_ProviceId == null ? null : num_ProviceId.ToString(),
                    total, query).FirstOrDefault();

                c.SetResult(p, c.ConvertFromXml(data), (int)total.Value, query.Value == DBNull.Value ? null : (string)query.Value);
            }));
        }
コード例 #10
0
 public static List <Product> GetList(GiaSinhVienEntities db)
 {
     return(db.Products.Where(w => w.Status == ProductStatus.Active).ToList());
 }
コード例 #11
0
 public static List <Province> GetList(GiaSinhVienEntities db)
 {
     return(db.Provinces.Where(w => w.Status == 1).ToList());
 }
コード例 #12
0
 public static Province GetByLink(GiaSinhVienEntities db, string link)
 {
     return(db.Provinces.FirstOrDefault(w => w.Link == link));
 }
コード例 #13
0
ファイル: Do.cs プロジェクト: GSVien/Code
        internal static PageResult <T> DoPage <T>(Func <PageController <T>, PageResult <T> > action, GiaSinhVienEntities db = null)
            where T : new()
        {
            var controller = new PageController <T>(db);

            try
            {
                if (db == null)
                {
                    controller.Db.Database.Connection.Open();
                }

                var r = action(controller);
                if (r == null)
                {
                    controller.Result.Items     = null;
                    controller.Result.PageIndex = 0;
                    controller.Result.PageSize  = 0;
                    controller.Result.PageCount = 0;
                    controller.Result.Total     = 0;
                }
                else
                {
                    controller.Result.ErrorCode = r.ErrorCode;
                    controller.Result.Message   = r.Message;
                    controller.Result.Items     = r.Items;
                    controller.Result.PageIndex = r.PageIndex;
                    controller.Result.PageSize  = r.PageSize;
                    controller.Result.PageCount = r.PageCount;
                    controller.Result.Total     = r.Total;
                }

                return(controller.Result);
            }
            catch (Exception ex)
            {
                controller.Result.Items     = controller.FailResult.Items;
                controller.Result.PageIndex = controller.FailResult.PageIndex;
                controller.Result.PageSize  = controller.FailResult.PageSize;
                controller.Result.PageCount = controller.FailResult.PageCount;
                controller.Result.Total     = controller.FailResult.PageCount;
                controller.SetError(ex.Message, -1);
            }
            finally
            {
                controller.Result.Query = null;
                controller.Db.Database.Connection.Close();
            }

            return(controller.Result);
        }
コード例 #14
0
ファイル: UserInfoDAO.cs プロジェクト: GSVien/Code
 public static UserInfo GetById(GiaSinhVienEntities db, long id)
 {
     return(db.UserInfoes.FirstOrDefault(f => f.Id == id).CloneObject());
 }
コード例 #15
0
ファイル: Controller.cs プロジェクト: GSVien/Code
 public DoController(GiaSinhVienEntities db = null)
     : base(db)
 {
     Result = new DoResult();
 }
コード例 #16
0
ファイル: Controller.cs プロジェクト: GSVien/Code
 public PageController(GiaSinhVienEntities db = null)
     : base(db)
 {
     FailResult = new PageResult <T>();
     Result     = new PageResult <T>();
 }
コード例 #17
0
 public static List <District> GetListByProviceId(GiaSinhVienEntities db, long proviceId)
 {
     return(db.Districts.Where(w => w.Status == 1 && w.ProvinceId == proviceId).ToList());
 }
コード例 #18
0
 public static List <SubProductCategory> GetListByCategoryId(GiaSinhVienEntities db, long categoryId)
 {
     return(db.SubProductCategories.Where(w => w.Status == SubProductCategoryStatus.Active && w.ProductCategoryId == categoryId).ToList());
 }