public async Task <int> Add(EF.GroupCategory args)
        {
            await unitOfWork.GroupCategoryRepository.AddAsync(args);

            unitOfWork.Commit();
            return(args.Id);
        }
 public async Task <EF.GroupCategory> Get(EF.GroupCategory args)
 {
     return(await unitOfWork.GroupCategoryRepository.Entities
            .Include(x => x.Group).ThenInclude(x => x.GroupMember)
            .FirstOrDefaultAsync(x => x.Id == args.Id &&
                                 x.CommunityId == args.CommunityId));
 }
 public IQueryable <EF.GroupCategory> Find(EF.GroupCategory args)
 {
     return(unitOfWork.GroupCategoryRepository.Entities
            .Where(x => x.Name.Contains(args.Name ?? x.Name) &&
                   x.CommunityId == args.CommunityId)
            .Include(x => x.Group).ThenInclude(x => x.GroupMember)
            .OrderBy(x => x.Name).AsQueryable());
 }
        public async Task <int> New([FromBody] EF.GroupCategory args)
        {
            var bll_gc = groupCategoryBusiness;
            var user   = HttpContext.Items["EndUser"] as EF.EndUser;

            args.CommunityId = user.Member.CommunityId;

            return(await bll_gc.Add(args));
        }
        public async Task Edit(EF.GroupCategory args)
        {
            var gc = await unitOfWork.GroupCategoryRepository.Entities.FirstAsync(x => x.Id == args.Id &&
                                                                                  x.CommunityId == args.CommunityId);

            gc.Name             = args.Name;
            gc.Description      = args.Description;
            gc.DateTimeModified = DateTime.Now;
            gc.ModifiedBy       = args.ModifiedBy;

            unitOfWork.Commit();
        }
Beispiel #6
0
        public void EditGroupCategory_Failed(EF.GroupCategory args)
        {
            var completed = false;

            mockUnitOfWork.Setup(x => x.Commit()).Callback(() =>
            {
                completed = true;
            });

            groupCategoryBusiness.Edit(args);

            Assert.True(!completed);
        }
        public async Task <IActionResult> Edit([FromBody] EF.GroupCategory args)
        {
            var bll_gc = groupCategoryBusiness;
            var user   = HttpContext.Items["EndUser"] as EF.EndUser;

            args.CommunityId      = user.Member.CommunityId;
            args.DateTimeModified = DateTime.Now;
            args.ModifiedBy       = user.Member.Name;

            await bll_gc.Edit(args);

            return(Json("Success!"));
        }
Beispiel #8
0
        public void AddGroupCategory_Success(EF.GroupCategory args)
        {
            var list  = mockGroupCategoryRepo.Object.Entities.ToList();
            var count = list.Count;

            mockUnitOfWork.Setup(x => x.Commit()).Callback(() =>
            {
                list.Add(args);
            });

            var id = groupCategoryBusiness.Add(args).Result;

            Assert.True(list.Count > count);
        }
        public async Task <IActionResult> Find([FromBody] EF.GroupCategory args)
        {
            var bll_gc = groupCategoryBusiness;
            var user   = HttpContext.Items["EndUser"] as EF.EndUser;

            args.CommunityId = user.Member.CommunityId;

            var res = from r in (await bll_gc.Find(args).ToListAsync())
                      select new
            {
                r.Id,
                r.Name,
                Groups  = r.Group.Count(),
                Members = r.Group.Sum(x => x.GroupMember.Select(y => y.MemberId).Distinct().Count())
            };

            return(Json(res));
        }
Beispiel #10
0
 public Task Delete(EF.GroupCategory args)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
        public void FindGroupCategory_HasNoResult(EF.GroupCategory args)
        {
            var res = groupCategoryBusiness.Find(args);

            Assert.True(res.Count() == 0);
        }