Exemple #1
0
        public bool AddServiceToUserProfile(int UserProfileId, int ServiceId)
        {
            UserProfile UserProfile = new UserProfile();
            UserProfile.UserProfileId = UserProfileId;

            Service Service = new Service();
            Service.ServiceId = ServiceId;

            return sys.AddServiceToUserProfile(UserProfile, Service);
        }
Exemple #2
0
        public bool AddServiceToUserProfile(UserProfile UserProfile, Service Service)
        {
            UserProfile = db.UserProfiles.Find(UserProfile.UserProfileId);
            Service = db.Services.Find(Service.ServiceId);

            UserProfile.Services.Add(Service);
            Service.UserProfiles.Add(UserProfile);
            db.Entry(UserProfile).State = EntityState.Modified;
            db.Entry(Service).State = EntityState.Modified;

            return db.SaveChanges() > 0;
        }
Exemple #3
0
        public bool CreateSelectingUserProfile(string login, string name, string password, string email, string sexo, string apptoken, int? userprofile)
        {
            LogBLL log = new LogBLL();
            bool success = false;

            try
            {
                Client cl = new Client();
                cl.Token = new Guid(apptoken);
                cl = bll.FindClient(cl);
                if (cl == null)
                    throw new SecurityException("Token inválido!");

                UserProfile up = new UserProfile();
                up.ClientId = cl.ClientId;
                if (userprofile != null)
                    up.UserProfileId = Convert.ToInt32(userprofile);

                up = bll.FindUserProfile(up);
                if (up == null || ! (up.UserProfileId > 0))
                    throw new SecurityException("Perfil de usuario não encontrado!");

                User user = new User();
                user.Login = login;
                user.Name = name;
                user.Password = password;
                user.Email = email;
                user.Sexo = sexo;
                user.UserProfileId = up.UserProfileId;

                success = bll.CreateUser(user);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return success;
        }
Exemple #4
0
        public bool CreateUserProfile(int ClientId, string Name)
        {
            UserProfile up = new UserProfile();
            up.Name = Name;
            up.ClientId = ClientId;

            return sys.CreateUserProfile(up);
        }
Exemple #5
0
 public bool CreateUserProfile(UserProfile userProfile)
 {
     db.UserProfiles.Add(userProfile);
     return db.SaveChanges() > 0;
 }
Exemple #6
0
        public UserProfile FindUserProfile(UserProfile up)
        {
            if (up.UserProfileId > 0)
            {
                return db.UserProfiles.Find(up.UserProfileId);
            }
            else if (up.ClientId > 0)
            {
                if (!String.IsNullOrEmpty(up.Name))
                    return db.UserProfiles.FirstOrDefault(p => p.Name.Equals(up.Name, StringComparison.InvariantCultureIgnoreCase) && p.ClientId == up.ClientId);
                else
                    return db.UserProfiles.FirstOrDefault(p => p.ClientId == up.ClientId);
            }

            return null;
        }