public async Task <IEnumerable <BacklogItemReadModel> > GetProjectBacklogItemsAsync(int projectId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var backlogItemDomainService = _backlogDomainServiceFactory.Get(unitOfWork);
         return(await backlogItemDomainService.GetProjectBacklogItemsAsync(projectId));
     }
 }
Ejemplo n.º 2
0
 public async Task <IEnumerable <SprintReadModel> > GetProjectSprintsAsync(int projectId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var sprintDomainService = _sprintDomainServiceFactory.Get(unitOfWork);
         return(await sprintDomainService.GetProjectSprintsAsync(projectId));
     }
 }
Ejemplo n.º 3
0
 public List <AppRole> GetRoleList()
 {
     using (var unitOfWOrk = _unitOfWorkFactory.Get())
     {
         _roleRepository.Context = unitOfWOrk;
         var roles = _roleRepository.Get(x => x.Deleted == false);
         return(roles);
     }
 }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 5
0
 public void Create(Employee obj)
 {
     obj.Active = true;
     ValidateEmployee(obj);
     using (var unitOfWork = _factory.Get())
     {
         _employeeRepo.Context = unitOfWork;
         _employeeRepo.Create(obj);
         unitOfWork.Commit();
     }
 }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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
            });
        }
Ejemplo n.º 9
0
 public async Task <UserSelfInfoReadModel> GetUserSelfInfoAsync(string userId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Get())
     {
         var userDomainService = _userDomainServiceFactory.Get(unitOfWork);
         return(await userDomainService.GetUserSelfInfoAsync(userId));
     }
 }
Ejemplo n.º 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
            });
        }
    }
}
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
 public FactController(IUnitOfWorkFactory unitOfWorkFactory, IODataQueryOptionsBinder binder, Settings settings)
 {
     _binder   = binder;
     _settings = settings;
     _uow      = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
Ejemplo n.º 13
0
 public DMuscleController(IUnitOfWorkFactory unitOfWorkFactory, Settings settings)
 {
     _settings = settings;
     _uow      = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
Ejemplo n.º 14
0
 public ApplicationSettingsController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
Ejemplo n.º 15
0
 public ApiUserController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
Ejemplo n.º 16
0
 /// <summary>
 ///
 /// </summary>
 public AuthorizationRequestController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }
Ejemplo n.º 17
0
 public DDateController(IUnitOfWorkFactory unitOfWorkFactory)
 {
     _uow = unitOfWorkFactory.Get <IALSUnitOfWork>();
 }