示例#1
0
        public Crud Create(string login, string password, string name)
        {
            LogBLL log = new LogBLL();
            Crud crud = new Crud();

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);
                crud.Name = name;
                crud = controller.Create(crud);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return crud;
        }
示例#2
0
        public Produto Create(string login, string password, Produto Produto)
        {
            LogBLL log = new LogBLL();

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                Produto = controller.Create(Produto);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return Produto;
        }
示例#3
0
        public Categoria Create(string login, string password, Categoria Categoria)
        {
            LogBLL log = new LogBLL();

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);
                Categoria = controller.Create(Categoria);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return Categoria;
        }
示例#4
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;
        }
示例#5
0
        public bool Delete(string login, string password, int ProdutoId)
        {
            LogBLL log = new LogBLL();
            bool valid = false;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);
                valid = controller.DeleteConfirmed(ProdutoId);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return valid;
        }
示例#6
0
        public Produto[] ListByUserPreferences(string login, string password)
        {
            LogBLL log = new LogBLL();
            Produto[] list;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                list = controller.ListByUserPreferences(u.UserId);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return list;
        }
示例#7
0
        public bool UpdateAndroidUserPreferences(string login, string password, int[] interesses)
        {
            LogBLL log = new LogBLL();
            bool valid = false;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);
                valid = controller.UpdateAndroidUserPreferences(u.UserId, interesses);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return valid;
        }
示例#8
0
        public Crud[] Index(string login, string password)
        {
            LogBLL log = new LogBLL();
            Crud[] list;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                list = controller.Index();
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return list;
        }
示例#9
0
        public Crud Find(string login, string password, int crudId)
        {
            LogBLL log = new LogBLL();
            Crud Crud = null;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                Crud = controller.Find(crudId);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return Crud;
        }
示例#10
0
        public User Login(string login, string password)
        {
            LogBLL log = new LogBLL();
            User user = new User();

            try
            {
                user.Login = login;
                user.Password = password;

                user = Authentication.Login(user);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
            }
            finally
            {
                log.Create();
            }

            return user;
        }
示例#11
0
        public User[] IndexFiltering(string login, string password, PerfilUsuarioEnum perfilusuario)
        {
            LogBLL log = new LogBLL();
            User[] list;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                list = db.Users.Where(us => us.UserProfileId == (int)perfilusuario).ToArray();
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return list;
        }
示例#12
0
        public bool Edit(string login, string password, Empresa Empresa)
        {
            LogBLL log = new LogBLL();
            bool valid = false;

            try
            {
                User u = new User();
                u.Login = login;
                u.Password = password;

                u = Authentication.Login(u);
                log.log.UserId = u.UserId;

                Authentication.HaveAccess(u);

                valid = controller.Edit(Empresa);
            }
            catch (Exception e)
            {
                log.log.Exception = e.Message;
                throw e;
            }
            finally
            {
                log.Create();
            }

            return valid;
        }