コード例 #1
0
        public EvaluationTableDataObject Create(int beMeasuredUserInfoID, int userInfoID)
        {
            BeMeasured      beMeasured      = this.entity.BeMeasured.FirstOrDefault(p => p.UserInfo.ID == beMeasuredUserInfoID);
            UserInfo        userInfo        = this.entity.UserInfo.FirstOrDefault(p => p.ID == userInfoID);
            EvaluationTable evaluationTable = this.DataEntity.Create();

            evaluationTable.BeMeasured = beMeasured;
            evaluationTable.UserInfo   = userInfo;
            evaluationTable.Ratio      = userInfo.MeasuredList.FirstOrDefault(p => p.BeMeasured.ID == beMeasured.ID).Ratio;
            List <EvaluationTableDetail> detailList = new List <EvaluationTableDetail>();
            TimeOver timeOver = this.entity.TimeOver.FirstOrDefault();
            int      year     = timeOver == null ? DateTime.Now.Year : timeOver.Year;

            evaluationTable.Year = year;
            List <Review> reviewList = this.entity.Review.Where(p => p.Year == year).ToList();

            foreach (Review review in reviewList)
            {
                EvaluationTableDetail detail = new EvaluationTableDetail();
                detail.EvaluationTable = evaluationTable;
                detail.Review          = review;
                detailList.Add(detail);
            }
            evaluationTable.EvaluationTableDetail = detailList;
            this.DataEntity.Add(evaluationTable);
            this.entity.SaveChanges();
            evaluationTable = this.DataEntity.FirstOrDefault(p => p.BeMeasured.UserInfo.ID == beMeasuredUserInfoID && p.UserInfo.ID == userInfoID);
            return(BHMapper.Map <EvaluationTable, EvaluationTableDataObject>(evaluationTable));
        }
コード例 #2
0
ファイル: BaseService.cs プロジェクト: jeffddjt/Evaluation
        public virtual TTarget Add(TTarget model)
        {
            TEntity ent    = BHMapper.Map <TTarget, TEntity>(model);
            TEntity result = this.DataEntity.Add(ent);

            this.entity.SaveChanges();
            return(BHMapper.Map <TEntity, TTarget>(result));
        }
コード例 #3
0
        public StyleOfWorkDataObject Update(int id, int score)
        {
            StyleOfWork styleOfWork = this.DataEntity.FirstOrDefault(p => p.ID == id);

            styleOfWork.Score = score;
            this.entity.SaveChanges();
            return(BHMapper.Map <StyleOfWork, StyleOfWorkDataObject>(styleOfWork));
        }
コード例 #4
0
ファイル: BaseService.cs プロジェクト: jeffddjt/Evaluation
        public virtual TTarget Update(TTarget model)
        {
            if (model.ID == 0)
            {
                return(this.Add(model));
            }
            TEntity ent  = BHMapper.Map <TTarget, TEntity>(model);
            TEntity data = this.DataEntity.FirstOrDefault(p => p.ID == ent.ID);

            this.entity.Entry(data).CurrentValues.SetValues(ent);
            this.entity.SaveChanges();
            return(model);
        }
コード例 #5
0
ファイル: BaseService.cs プロジェクト: jeffddjt/Evaluation
 public virtual List <TTarget> GetList(Expression <Func <TEntity, bool> > condition = null)
 {
     if (condition == null)
     {
         List <TEntity> list = this.DataEntity.ToList();
         return(BHMapper.Map <List <TEntity>, List <TTarget> >(list));
     }
     else
     {
         List <TEntity> list = this.DataEntity.Where(condition).ToList();
         return(BHMapper.Map <List <TEntity>, List <TTarget> >(list));
     }
 }
コード例 #6
0
        public override DepartmentDataObject Add(DepartmentDataObject model)
        {
            if (model.ParentID == 0)
            {
                return(base.Add(model));
            }
            Department dept    = this.DataEntity.FirstOrDefault(p => p.ID == model.ParentID);
            Department deptAdd = this.DataEntity.Create();

            deptAdd.Name = model.Name;
            dept.Children.Add(deptAdd);
            this.entity.SaveChanges();
            return(BHMapper.Map <Department, DepartmentDataObject>(deptAdd));
        }
コード例 #7
0
        public List <UserInfoDataObject> GetList(int pageSize, int pageIndex, Expression <Func <UserInfo, bool> > condition = null)
        {
            List <UserInfo> list;

            if (condition == null)
            {
                list = this.DataEntity.OrderBy(p => p.WorkNo).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            else
            {
                list = this.DataEntity.Where(condition).OrderBy(p => p.WorkNo).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            return(BHMapper.Map <List <UserInfo>, List <UserInfoDataObject> >(list));
        }
コード例 #8
0
ファイル: BaseService.cs プロジェクト: jeffddjt/Evaluation
        public virtual TTarget GetOne(Expression <Func <TEntity, bool> > condition = null)
        {
            TEntity temp;

            if (condition == null)
            {
                temp = this.DataEntity.FirstOrDefault();
            }
            else
            {
                temp = this.DataEntity.Where(condition).FirstOrDefault();
            }
            return(BHMapper.Map <TEntity, TTarget>(temp));
        }
コード例 #9
0
        public override UserRoleDataObject Update(UserRoleDataObject model)
        {
            UserRole userRole = this.DataEntity.FirstOrDefault(p => p.ID == model.ID);

            if (userRole == null)
            {
                return(base.Update(model));
            }
            else
            {
                userRole.Name = model.Name;
                this.entity.SaveChanges();
                return(BHMapper.Map <UserRole, UserRoleDataObject>(userRole));
            }
        }
コード例 #10
0
ファイル: SystemService.cs プロジェクト: jeffddjt/Evaluation
 public static ArticleDataObject GetArticle()
 {
     using (BHWebEntity entity = new BHWebEntity())
     {
         Article article = entity.Article.FirstOrDefault();
         if (article == null)
         {
             return(new ArticleDataObject());
         }
         else
         {
             return(BHMapper.Map <Article, ArticleDataObject>(article));
         }
     }
 }
コード例 #11
0
        public StyleOfWorkDataObject Create(int id, int userInfoID)
        {
            BeMeasured  beMeasured  = this.entity.BeMeasured.FirstOrDefault(p => p.UserInfo.ID == id);
            UserInfo    userInfo    = this.entity.UserInfo.FirstOrDefault(p => p.ID == userInfoID);
            StyleOfWork styleOfWork = this.DataEntity.Create();

            styleOfWork.BeMeasured   = beMeasured;
            styleOfWork.BeMeasuredID = beMeasured.ID;
            styleOfWork.UserInfo     = userInfo;
            styleOfWork.Ratio        = userInfo.MeasuredList.FirstOrDefault(p => p.BeMeasured.ID == beMeasured.ID).Ratio;
            int year = this.entity.TimeOver.FirstOrDefault().Year;

            styleOfWork.Year = year;
            this.DataEntity.Add(styleOfWork);
            this.entity.SaveChanges();
            styleOfWork = this.DataEntity.FirstOrDefault(p => p.BeMeasured.UserInfo.ID == id && p.UserInfo.ID == userInfoID && p.Year == year);
            return(BHMapper.Map <StyleOfWork, StyleOfWorkDataObject>(styleOfWork));
        }
コード例 #12
0
ファイル: ReviewService.cs プロジェクト: jeffddjt/Evaluation
        public override ReviewDataObject Add(ReviewDataObject model)
        {
            if (model.ParentID == 0)
            {
                return(base.Add(model));
            }
            Review parent = this.DataEntity.FirstOrDefault(p => p.ID == model.ParentID);
            Review newOne = this.DataEntity.Create();

            newOne.Year    = model.Year;
            newOne.Name    = model.Name;
            newOne.Score   = model.Score;
            newOne.Content = model.Content;
            newOne.Sort    = model.Sort;
            parent.Children.Add(newOne);
            parent.Score = parent.Children.Sum(p => p.Score);
            this.entity.SaveChanges();
            return(BHMapper.Map <Review, ReviewDataObject>(newOne));
        }
コード例 #13
0
        public override UserInfoDataObject Add(UserInfoDataObject model)
        {
            UserInfo   userinfo = this.DataEntity.Create();
            Department dept     = this.entity.Department.FirstOrDefault(p => p.ID == model.DepartmentID);
            Duties     duties   = this.entity.Duties.FirstOrDefault(p => p.ID == model.DutiesID);

            userinfo.UserName     = model.UserName;
            userinfo.Password     = "******";
            userinfo.Professional = model.Professional;
            userinfo.WorkNo       = model.WorkNo;
            userinfo.MajorLeader  = model.MajorLeader;
            userinfo.Department   = dept;
            userinfo.Duties       = duties;
            userinfo.Secretary    = model.Secretary;
            userinfo.Director     = model.Director;
            userinfo.Instructor   = model.Instructor;
            this.DataEntity.Add(userinfo);
            this.entity.SaveChanges();
            return(BHMapper.Map <UserInfo, UserInfoDataObject>(userinfo));
        }
コード例 #14
0
        public override UserInfoDataObject Update(UserInfoDataObject model)
        {
            if (model.ID == 0)
            {
                return(Add(model));
            }
            UserInfo   userinfo = this.DataEntity.FirstOrDefault(p => p.ID == model.ID);
            Department dept;

            if (model.DepartmentID != 0)
            {
                dept = this.entity.Department.FirstOrDefault(p => p.ID == model.DepartmentID);
                userinfo.Department = dept;
            }
            else
            {
                userinfo.Department?.UserList.Remove(userinfo);
            }

            Duties duties;

            if (model.DutiesID != 0)
            {
                duties          = this.entity.Duties.FirstOrDefault(p => p.ID == model.DutiesID);
                userinfo.Duties = duties;
            }
            else
            {
                userinfo.Duties?.UserList.Remove(userinfo);
            }
            userinfo.UserName     = model.UserName;
            userinfo.Professional = model.Professional;
            userinfo.WorkNo       = model.WorkNo;
            userinfo.MajorLeader  = model.MajorLeader;
            userinfo.Secretary    = model.Secretary;
            userinfo.Director     = model.Director;
            userinfo.Instructor   = model.Instructor;
            this.entity.SaveChanges();
            return(BHMapper.Map <UserInfo, UserInfoDataObject>(userinfo));
        }
コード例 #15
0
        public UserInfoDataObject CheckLogin(string workNo, string password)
        {
            UserInfo userInfo = this.DataEntity.FirstOrDefault(p => p.WorkNo == workNo && p.Password == password);

            return(BHMapper.Map <UserInfo, UserInfoDataObject>(userInfo));
        }