public async Task <IEnumerable <BacklogItemReadModel> > GetProjectBacklogItemsAsync(int projectId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var backlogItemDomainService = _backlogDomainServiceFactory.Get(unitOfWork);
         return(await backlogItemDomainService.GetProjectBacklogItemsAsync(projectId));
     }
 }
 public async Task <IEnumerable <SprintReadModel> > GetProjectSprintsAsync(int projectId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var sprintDomainService = _sprintDomainServiceFactory.Get(unitOfWork);
         return(await sprintDomainService.GetProjectSprintsAsync(projectId));
     }
 }
示例#3
0
 public List <AppRole> GetRoleList()
 {
     using (var unitOfWOrk = _unitOfWorkFactory.Get())
     {
         _roleRepository.Context = unitOfWOrk;
         var roles = _roleRepository.Get(x => x.Deleted == false);
         return(roles);
     }
 }
        public async Task <IResult> CreateProjectAsync(ProjectCreateWriteModel project, string creatorId)
        {
            using (var unitOfWork = _unitOfWorkFactory.Get(false))
            {
                var projectDomainService = _projectDomainServiceFactory.Get(unitOfWork);

                projectDomainService.CreateProject(project, creatorId);

                return(await CreateResultAsync(unitOfWork));
            }
        }
 public void Create(Employee obj)
 {
     obj.Active = true;
     ValidateEmployee(obj);
     using (var unitOfWork = _factory.Get())
     {
         _employeeRepo.Context = unitOfWork;
         _employeeRepo.Create(obj);
         unitOfWork.Commit();
     }
 }
        public bool IsOverlappingEvent(string userName, DateTime date, string startTime, string endTime)
        {
            using (var unitOfWork = _unitOfWorkFactory.Get())
            {
                _userRepository.Context          = unitOfWork;
                _eventScheduleRepository.Context = unitOfWork;
                var user = _userRepository.GetSingle(x => x.UserName == userName && x.Deleted == false);
                if (user == null)
                {
                    throw new ValidationException($"{userName} not found");
                }
                // Find EventSchedules
                var eventStartDate = date.AppendTime(startTime);
                var eventEndDate   = date.AppendTime(endTime);
                if (eventEndDate <= eventStartDate)
                {
                    throw new ValidationException("End date should be greater than event start date.");
                }

                var schedules = _eventScheduleRepository.Get(x => x.Organizer.Id == user.Id && ((eventStartDate <= x.StartDateTime && eventEndDate > x.StartDateTime) || (eventStartDate > x.StartDateTime && eventStartDate <= x.EndDateTime)));
                if (schedules.Count > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
示例#7
0
        public async Task <User> AuthenticateUser(string username, string password)
        {
            var unitOfWork = _unitOfWorkFactory.Get();

            var usersQueryResults = await unitOfWork
                                    .UserRepo
                                    .FindMatchingResults(username);

            var exactMatches = usersQueryResults
                               .Where(user => user.Username.Equals(username, StringComparison.InvariantCultureIgnoreCase) && user.ValidatePassword(password))
                               .ToList();

            if (!exactMatches.Any())
            {
                return(null);
            }

            if (exactMatches.Count() > 1)
            {
                throw new Exception($"Encountered username {username} with duplicate accounts.");
            }

            return(exactMatches
                   .First());
        }
示例#8
0
        public async Task <OperationResponse> AddRestaurant(Restaurant restaurant)
        {
            var unitOfWork = _unitOfWorkFactory.Get();

            var stateExists = await unitOfWork
                              .StateRepo
                              .Exists(restaurant.StateCode);

            if (!stateExists)
            {
                return new OperationResponse
                       {
                           OpCode  = OpCodes.InvalidOperation,
                           Message = $"Unrecognized state code {restaurant.StateCode}."
                       }
            }
            ;

            var identicalRestaurants = await unitOfWork
                                       .RestaurantRepo
                                       .FindMatchingResults(restaurant.Name, restaurant.City, restaurant.StateCode);

            if (identicalRestaurants.Any())
            {
                return new OperationResponse
                       {
                           OpCode  = OpCodes.InvalidOperation,
                           Message = "Identical record exists."
                       }
            }
            ;

            unitOfWork
            .RestaurantRepo
            .Add(restaurant);

            await unitOfWork
            .CommitAsync();

            return(new OperationResponse
            {
                OpCode = OpCodes.Success
            });
        }
示例#9
0
 public async Task <UserSelfInfoReadModel> GetUserSelfInfoAsync(string userId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var userDomainService = _userDomainServiceFactory.Get(unitOfWork);
         return(await userDomainService.GetUserSelfInfoAsync(userId));
     }
 }
示例#10
0
        public async Task <OperationResponse> DeleteReview(long reviewId)
        {
            var unitOfWork = _unitOfWorkFactory
                             .Get();

            var review = unitOfWork
                         .ReviewRepo
                         .Get(reviewId);

            if (review == null)
            {
                return new OperationResponse {
                           OpCode = OpCodes.ResourceNotFound
                }
            }
            ;

            var activeUser = unitOfWork
                             .UserRepo
                             .Get(_activeUserId);

            if (activeUser == null)
            {
                return new OperationResponse {
                           OpCode = OpCodes.UnauthorizedOperation
                }
            }
            ;

            if (!review.AuthorUsername.Equals(activeUser.Username))
            {
                return new OperationResponse {
                           OpCode = OpCodes.InsufficientPermissions
                }
            }
            ;

            unitOfWork
            .ReviewRepo
            .Remove(review.Id);

            await unitOfWork
            .CommitAsync();

            return(new OperationResponse {
                OpCode = OpCodes.Success
            });
        }
    }
}
示例#11
0
        public async Task <List <Review> > GetReviewsBy(long userId)
        {
            var unitOfWork = _unitOfWorkFactory
                             .Get();

            if (userId < 0)
            {
                return(new List <Review>());
            }

            var results = await unitOfWork
                          .ReviewRepo
                          .FindMatchingResults(authorId : userId);

            return(results);
        }
示例#12
0
 public FactController(IUnitOfWorkFactory unitOfWorkFactory, IODataQueryOptionsBinder binder, Settings settings)
 {
     _binder   = binder;
     _settings = settings;
     _uow      = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
示例#13
0
 public DMuscleController(IUnitOfWorkFactory unitOfWorkFactory, Settings settings)
 {
     _settings = settings;
     _uow      = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
示例#14
0
 public ApplicationSettingsController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
示例#15
0
 public ApiUserController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
示例#16
0
 /// <summary>
 ///
 /// </summary>
 public AuthorizationRequestController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
示例#17
0
 public DDateController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }