Esempio n. 1
0
        public IHttpActionResult AddToPost(UserInDeptRoleShortViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userInDeptRole = _userInDeptRolesService.GetAll().FirstOrDefault(x => x.DepartmentDeptRoleId == model.DeptId);

            _userInDeptRolesService.Delete(userInDeptRole, true);
            _db.SaveChanges();

            UserInDeptRole item = Mapper.Map <UserInDeptRoleShortViewModel, UserInDeptRole>(model);

            _userInDeptRolesService.Add(item);
            _db.SaveChanges();
            return(Ok());
        }
Esempio n. 2
0
        public IQueryable <Quota> GetMyDeptQuota(string userId)
        {
            int id = int.Parse(userId);
            IQueryable <ICollection <Quota> > items = _userInDeptRolesService
                                                      .GetAll()
                                                      .Where(x => x.UserId == id)
                                                      .Select(x => x.DepartmentDeptRole.Department.Quotas);

            var list = items.SelectMany(x => x.Select(c => c))
                       .Where(x => x.DeadLineTime > DateTime.UtcNow && x.IsDeleted == false && x.IsRefuse == false);

            return(list);
        }