Esempio n. 1
0
        public void BeVoted(int id)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            candidate.BidCount += 1;
            db.SubmitChanges();
        }
Esempio n. 2
0
        public ManageEditApplyDisplayModel(EditApplyModel eam)
        {
            CandidateRepository cr = new CandidateRepository();

            this.eam = eam;
            this.cm  = cr.GetInfoById(eam.RelatedCandidateId);
        }
Esempio n. 3
0
        public void Delete(int id)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            db.CandidateModel.DeleteOnSubmit(candidate);
            db.EditApplyModel.DeleteAllOnSubmit(db.EditApplyModel.Where(eam => eam.RelatedCandidateId == id));
        }
Esempio n. 4
0
        public void BeAdjusted(int id, int adjustAmount)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            candidate.BidCount  += adjustAmount;
            candidate.BidAdjust += adjustAmount;
            db.SubmitChanges();
        }
Esempio n. 5
0
        public void RelatedVoteIsWithdrawed(int id)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            candidate.BidCount -= 1;
            if (candidate.BidAdjust < 0)
            {
                candidate.BidAdjust += 1;
            }
            db.SubmitChanges();
        }
Esempio n. 6
0
        public void Update(CandidateModel cm)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == cm.Id);

            candidate.Name         = cm.Name;
            candidate.Department   = cm.Department;
            candidate.Role         = cm.Role;
            candidate.Type         = cm.Type;
            candidate.Tel          = cm.Tel;
            candidate.Introduction = cm.Introduction;
            candidate.Story        = cm.Story;
            candidate.Priority     = cm.Priority;
            db.SubmitChanges();
        }
Esempio n. 7
0
        public void SwitchDisplay(int id)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            if (candidate.Hidden == 1)
            {
                candidate.Hidden = 0;
                candidate.Type   = candidate.Type % 10;
            }
            else
            {
                candidate.Hidden = 1;
            }
            db.SubmitChanges();
        }
Esempio n. 8
0
        /// <summary>
        /// Check duplicate candidate in db
        /// </summary>
        /// <param name="target"></param>
        /// <returns>-2:Serious Duplicate, -1: No duplicate, >0:potential duplicate with duplicate id</returns>
        public int CheckDuplicate(CandidateModel target)
        {
            List <CandidateModel> cl = db.CandidateModel.Where(c => c.Name == target.Name).ToList <CandidateModel>();

            if (cl.Count > 0)
            {
                foreach (CandidateModel cm in cl)
                {
                    if (cm.Department == target.Department && cm.Role == target.Role)
                    {
                        return(-2);
                    }
                }
                return(cl.First().Id);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 9
0
 partial void DeleteCandidateModel(CandidateModel instance);
Esempio n. 10
0
 partial void UpdateCandidateModel(CandidateModel instance);
Esempio n. 11
0
 partial void InsertCandidateModel(CandidateModel instance);
Esempio n. 12
0
        public CandidateModel GetInfoById(int id)
        {
            CandidateModel candidate = db.CandidateModel.First(c => c.Id == id);

            return(candidate);
        }
Esempio n. 13
0
 public void Insert(CandidateModel c)
 {
     db.CandidateModel.InsertOnSubmit(c);
 }