示例#1
0
 public UserQuest GetUserQuest(Guid userQuestId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <UserQuest>(_userQuestRepository.GetUserQuest(userQuestId)));
     }
 }
 private Faw.Models.Domain.Quest GetQuestInternal(Guid questId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(_questRepository.GetById(questId));
     }
 }
示例#3
0
 public Quest GetById(Guid questId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Quest>(_questRepository.GetById(questId)));
     }
 }
        private void SaveInternal(Achivment achivment)
        {
            var now = DateTime.UtcNow;

            using (var contextScope = ContextScopeFactory.Create())
            {
                var domainAchivment = _mapper.Map <Faw.Models.Domain.Achivment>(achivment);

                domainAchivment.UpdatedOn = domainAchivment.CreatedOn = now;

                _achivmentRepository.Save(domainAchivment);

                var expIds = domainAchivment.ExpressionProperties.Select(x => x.EntityId);

                var toRemove =
                    _expressionPropertyRepository.GetWhere(
                        x => !expIds.Contains(x.EntityId) && x.AchivmentId == domainAchivment.EntityId)
                    .Select(x => x.EntityId);

                _expressionPropertyRepository.DeleteRange(toRemove);

                EditAchivmentProperties(domainAchivment.ExpressionProperties, domainAchivment.EntityId);

                contextScope.SaveChanges();
            }
        }
 public Family GetUserFamily(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Family>(_familyRepository.GetUserFamily(userId)));
     }
 }
        private void EditAchivmentProperties(IEnumerable <Faw.Models.Domain.ExpressionProperty> expressionProperties, Guid achivmentId)
        {
            using (var contextScope = ContextScopeFactory.Create())
            {
                foreach (var expressionProperty in expressionProperties.ToList())
                {
                    var expr = _expressionPropertyRepository.Get(expressionProperty.EntityId);

                    if (expr == null)
                    {
                        expressionProperty.LeftPropertyValueId  = expressionProperty.LeftPropertyValue.EntityId;
                        expressionProperty.RightPropertyValueId = expressionProperty.RightPropertyValue.EntityId;
                    }
                    else
                    {
                        expressionProperty.LeftPropertyValue.EntityId  = expressionProperty.LeftPropertyValueId;
                        expressionProperty.RightPropertyValue.EntityId = expressionProperty.RightPropertyValueId;
                    }

                    _expressionPropertyRepository.Save(expressionProperty);
                    UpdatePropertyValue(expressionProperty.LeftPropertyValue);
                    UpdatePropertyValue(expressionProperty.RightPropertyValue);
                }

                contextScope.SaveChanges();
            }
        }
 public Family Get(Guid familyId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Family>(_familyRepository.GetById(familyId)));
     }
 }
 private Faw.Models.Domain.User GetUserInternal(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(_userRepository.GetById(userId));
     }
 }
 public User Get(string emailOrLogin)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <User>(_userRepository.Get(emailOrLogin)));
     }
 }
 public User Get(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <User>(_userRepository.GetById(userId)));
     }
 }
示例#11
0
 private Expirience GetInternalByExpirience(decimal expirience)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Expirience>(_expirienceRepository.GetByExpirience(expirience)));
     }
 }
 public UserType GetByName(string name)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <UserType>(_userTypeRepository.Get(name)));
     }
 }
示例#13
0
 public Expirience GetExpirience(int level)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Expirience>(_expirienceRepository.Get(level)));
     }
 }
示例#14
0
 public IEnumerable <Quest> GetQuests(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <IEnumerable <Quest> >(_questRepository.GetWhere(x => x.CreatedById == userId)));
     }
 }
        public UserVerifyResult Verify(Guid token)
        {
            var account = _accountQueryService.GetByToken(token);

            if (account == null)
            {
                return(UserVerifyResult.TokenChanged);
            }

            var now = DateTime.UtcNow;

            if (account.TokenExpireDate > now)
            {
                return(UserVerifyResult.TokenExpired);
            }

            if (account.VerifiedOn.HasValue)
            {
                return(UserVerifyResult.AlreadyVerified);
            }

            using (var contextScope = ContextScopeFactory.Create())
            {
                account.VerifiedOn      = DateTime.Now;
                account.Token           = null;
                account.TokenExpireDate = null;
                account.Status          = Models.Enums.AccountStatus.Active;

                _accountRepository.Update(Mapper.Map <Account>(account));

                contextScope.SaveChanges();
            }

            return(UserVerifyResult.Ok);
        }
示例#16
0
 public IEnumerable <UserQuest> GetUserQuests(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <IEnumerable <UserQuest> >(_userQuestRepository.GetUserQuests(userId)));
     }
 }
示例#17
0
 public IEnumerable <Achivment> Get()
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <IEnumerable <Achivment> >(_achivmentRepository.Get()));
     }
 }
示例#18
0
 public IOrderedEnumerable <Expirience> GetExpirienceList()
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <IOrderedEnumerable <Expirience> >(
                  _expirienceRepository.GetWhere(x => x.EntityId != Guid.Empty).OrderByDescending(x => x.Level)));
     }
 }
示例#19
0
 public UserType GetByName(string name)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <UserType>(
                  _userTypeRepository.GetWhere(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))));
     }
 }
 public IEnumerable <User> Find(string searchTerm)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <IEnumerable <User> >(
                  _userRepository.Find(searchTerm)));
     }
 }
示例#21
0
 public IEnumerable <Achivment> GetUserAchivments(Guid userId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <IEnumerable <Achivment> >(
                  _achivmentRepository.GetUserAchivment(userId).Select(x => x.Achivment)));
     }
 }
示例#22
0
        public IEnumerable <Quest> GetAvailableFamilyUserQuests(Guid familyId, Guid userId)
        {
            using (ContextScopeFactory.CreateReadOnly())
            {
                var userQuestIds = _userQuestRepository.GetWhere(x => x.UserId == userId).AsNoTracking().Select(x => x.QuestId).ToList();

                return
                    (Mapper.Map <IEnumerable <Quest> >(
                         _questRepository.GetWhere(x => x.FamilyId == familyId && !userQuestIds.Contains(x.EntityId))));
            }
        }
示例#23
0
 public Account GetByToken(Guid token)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <Account>(
                  _accountRepository.GetWhere(
                      x =>
                      x.Token == token)));
     }
 }
示例#24
0
        private Faw.Models.Domain.Family GetFamilyInternal(Guid familyId)
        {
            using (ContextScopeFactory.CreateReadOnly())
            {
                var result = _familyRepository.GetById(familyId);

                result.CreatedBy = null;
                result.FamilyMemebers = null;

                return _familyRepository.GetById(familyId);
            }
        }
示例#25
0
 public Account GetByEmailOrLogin(string emailOrlogin)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return
             (Mapper.Map <Account>(
                  _accountRepository.GetWhere(
                      x =>
                      x.Email.Equals(emailOrlogin, StringComparison.OrdinalIgnoreCase) ||
                      x.Login.Equals(emailOrlogin, StringComparison.OrdinalIgnoreCase)).SingleOrDefault()));
     }
 }
示例#26
0
        public void Create(Family family)
        {
            var domainFamily = Mapper.Map<Faw.Models.Domain.Family>(family);

            using (var contextScope = ContextScopeFactory.Create())
            {
                domainFamily.CreatedOn = domainFamily.UpdatedOn = DateTime.UtcNow;
                
                _familyRepository.Save(domainFamily);

                contextScope.SaveChanges();
            }
        }
        public void Edit(User user)
        {
            using (var contextScope = ContextScopeFactory.Create())
            {
                //var domainUser = _userRepository.GetById(user.UserId);

                //Mapper.Map(user, domainUser);

                _userRepository.Save(_mapper.Map <Faw.Models.Domain.User>(user));

                contextScope.SaveChanges();
            }
        }
示例#28
0
        public void AddNewFamilyMember(Guid familyId, Guid userId)
        {
            //TODO: Add check if family exists. and user havent been assigned to any family.
            using (var contextScope = ContextScopeFactory.Create())
            {
                var domainUser = _userRepository.GetById(userId);

                domainUser.FamilyId = familyId;

                _userRepository.Update(domainUser);

                contextScope.SaveChanges();
            }
        }
示例#29
0
        public Achivment Get(Guid achivmentId)
        {
            using (ContextScopeFactory.CreateReadOnly())
            {
                var res = _achivmentRepository.Get(achivmentId);

                foreach (var expressionProperty in res.ExpressionProperties)
                {
                    expressionProperty.Achivment = null;
                }

                return(Mapper.Map <Achivment>(res));
            }
        }
        public void Create(Quest quest)
        {
            var domainQuest = Mapper.Map <Faw.Models.Domain.Quest>(quest);

            using (var contextScope = ContextScopeFactory.Create())
            {
                domainQuest.CreatedOn  = domainQuest.UpdatedOn = DateTime.UtcNow;
                domainQuest.Expirience = _expirienceQueryService.CalculateExpirience(domainQuest.RequiredLevel,
                                                                                     quest.QuestСomplexity);

                _questRepository.Insert(domainQuest);

                contextScope.SaveChanges();
            }
        }