示例#1
0
        public Operation <long> AddUserContributionToGroup(ContributeModel model)
        {
            return(Operation.Create(() =>
            {
                var existInGroup = _repo.Query <UserGroup>().Where(ug => ug.UserId == model.UserId && ug.GroupId == model.GroupId).FirstOrDefault();
                if (existInGroup == null)
                {
                    throw new Exception("This User does not belong to this group");
                }

                var contribution = _repo.Query <Contribute>().Where(c => c.UserId == model.UserId && c.MonthId == model.MonthId &&
                                                                    c.GroupId == model.GroupId).FirstOrDefault();
                if (contribution != null)
                {
                    throw new Exception("This User has contributed in this group");
                }

                var yearId = _repo.Query <Year>().Where(y => y.YearName == DateTime.Now.Year.ToString()).Select(y => y.YearId).FirstOrDefault();
                var entity = new Contribute()
                {
                    Amount = 10000,
                    GroupId = model.GroupId,
                    MonthId = model.MonthId,
                    UserId = model.UserId,
                    TransactionDate = DateTime.Now,
                    YearId = yearId
                };
                _repo.Add <Contribute>(entity);
                _repo.SaveChanges().Unwrap();
                return (long)entity.ContributeId;
            }));
        }
示例#2
0
 public ContributeModel(Contribute contribute)
 {
     this.Assign(contribute);
     this.User  = new UserModel(contribute.User);
     this.Month = new MonthModel(contribute.Month);
     this.Year  = new YearModel(contribute.Year);
     this.Group = new GroupModel(contribute.Group);
 }
示例#3
0
        private void contributeToFRCScoutingV2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var contribute = new Contribute();

            contribute.Show();
        }