Example #1
0
        public bool AddServiceToClient(int ClientId, int ServiceId)
        {
            Client Client = new Client();
            Client.ClientId = ClientId;

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

            return sys.AddServiceToClient(Client, Service);
        }
Example #2
0
        public bool AddServiceToClient(Client Client, Service Service)
        {
            Client = db.Clients.Find(Client.ClientId);
            Service = db.Services.Find(Service.ServiceId);

            Client.Services.Add(Service);
            Service.Clients.Add(Client);
            db.Entry(Client).State = EntityState.Modified;
            db.Entry(Service).State = EntityState.Modified;

            return db.SaveChanges() > 0;
        }
Example #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;
        }
Example #4
0
 public bool CreateClient(Client client)
 {
     db.Clients.Add(client);
     return db.SaveChanges() > 0;
 }
Example #5
0
        public Client FindClient(Client cl)
        {
            if (cl.ClientId > 0)
            {
                return db.Clients.Find(cl.ClientId);
            }
            else if (!String.IsNullOrEmpty(cl.Name))
            {
                return db.Clients.First(c => c.Name.Equals(cl.Name, StringComparison.InvariantCultureIgnoreCase));
            }
            else if (! String.IsNullOrEmpty(cl.Token.ToString()))
            {
                return db.Clients.First(c => c.Token.Equals(cl.Token));
            }

            return null;
        }