Exemplo n.º 1
0
 public UserCriteriaModel(UserCriteriaEntity entity)
 {
     Username    = entity.USERNAME;
     Criteria    = entity.CRITERIA;
     HasAccess   = entity.HAS_ACCESS;
     HasCriteria = entity.CRITERIA != null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the UserCriteria of the specified user.
        /// If a user does not have any criteria,
        /// a default setting will be created for them based on their role.
        /// </summary>
        /// <param name="db">BridgeCareContext</param>
        /// <param name="userInformation">UserInformationModel</param>
        /// <returns>UserCriteriaModel</returns>
        public UserCriteriaModel GetOwnUserCriteria(BridgeCareContext db, UserInformationModel userInformation)
        {
            if (!db.UserCriteria.Any(criteria => criteria.USERNAME == userInformation.Name))
            {
                log.Info($"User '{userInformation.Name}' has logged in for the first time.");
                var newUserCriteria = new UserCriteriaEntity(GenerateDefaultUserCriteria(userInformation));
                db.UserCriteria.Add(newUserCriteria);
                db.SaveChanges();
                return(new UserCriteriaModel(newUserCriteria));
            }
            var userCriteria = db.UserCriteria.Single(criteria => criteria.USERNAME == userInformation.Name);

            return(new UserCriteriaModel(userCriteria));
        }
Exemplo n.º 3
0
 public void UpdateUserCriteria(UserCriteriaEntity entity)
 {
     entity.USERNAME   = Username;
     entity.CRITERIA   = Criteria;
     entity.HAS_ACCESS = HasAccess;
 }