Exemplo n.º 1
0
        /// <summary>
        /// Get person by id Dto
        /// </summary>
        /// <param name="id">Id person to search</param>
        /// <returns>Return object person</returns>
        public static PersonDto GetDto(long id, ModelUnibookContainer objContex)
        {
            PersonDto personDto = null;

            try
            {
                Person person = PersonDal.Get(id, objContex);
                personDto          = new PersonDto();
                personDto.PersonId = person.PersonId;
                personDto.Name     = person.Name;
                personDto.LastName = person.LastName;
                personDto.BirthDay = person.Birthday;
                personDto.Deleted  = person.Deleted;
                personDto.Gender   = GenderBrl.GetDto(person.Gender.GenderId, objContex);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(personDto);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get list gender
        /// </summary>
        /// <param name="objContex">Get table to object</param>
        /// <returns></returns>
        public static List <GenderDto> Get(ModelUnibookContainer objContex)
        {
            try
            {
                List <GenderDto> genderList = new List <GenderDto>();
                foreach (var item in GenderListDal.Get(objContex))
                {
                    GenderDto gender = new GenderDto()
                    {
                        Name     = item.Name,
                        GenderId = item.GenderId,
                    };

                    genderList.Add(gender);
                }

                return(genderList);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get person by id
        /// </summary>
        /// <param name="id">Id person to search</param>
        /// <returns>Return object person</returns>
        public static Person Get(long id, ModelUnibookContainer objContex)
        {
            Person personReturn = null;

            try
            {
                bool exist = (from person in objContex.Person
                              where person.PersonId == id
                              select person).Count() > 0;
                if (exist)
                {
                    personReturn = (from person in objContex.Person
                                    where person.PersonId == id
                                    select person).Single <Person>();
                }
            }
            catch (DbEntityValidationException ex)
            {
                System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
                throw ex;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
                throw ex;
            }

            return(personReturn);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get list gender
        /// </summary>
        /// <param name="objContex">Get table to object</param>
        /// <returns></returns>
        public static List <RoleDto> Get(ModelUnibookContainer objContex)
        {
            try
            {
                List <RoleDto> roleList = new List <RoleDto>();
                foreach (var item in RoleListDal.Get(objContex))
                {
                    RoleDto role = new RoleDto()
                    {
                        Name   = item.Name,
                        RoleId = item.RoleId,
                    };

                    roleList.Add(role);
                }

                return(roleList);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Add new password.
 /// </summary>
 /// <param name="password"></param>
 /// <param name="objContex"></param>
 public static bool AddNewPassword(Password password,
                                   ModelUnibookContainer objContex)
 {
     try
     {
         Password old = (from pass in objContex.Password
                         where pass.User.UserId == password.User.UserId &&
                         pass.State == 1
                         select pass)
                        .SingleOrDefault <Password>();
         password.Date  = new DateTime();
         password.State = 1;
         if (old != null)
         {
             old.State = 0;
             objContex.Password.Add(password);
         }
         else
         {
             objContex.Password.Add(password);
         }
         objContex.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
         throw ex;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Get list person
        /// </summary>
        /// <param name="objContex">Get table to object</param>
        /// <returns></returns>
        public static List <FacultyDto> Get(ModelUnibookContainer objContex)
        {
            try
            {
                List <FacultyDto> facultyList = new List <FacultyDto>();
                foreach (var item in FacultyListDal.Get(objContex))
                {
                    FacultyDto faculty = new FacultyDto()
                    {
                        Deleted   = item.Deleted,
                        Name      = item.Name,
                        FacultyId = item.FacultyId
                    };

                    facultyList.Add(faculty);
                }

                return(facultyList);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get a user with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static UserDto GetDto(long id, ModelUnibookContainer objContex)
        {
            UserDto userDto = null;

            try
            {
                User user = UserDal.Get(id, objContex);
                userDto         = new UserDto();
                userDto.Email   = user.Email;
                userDto.Deleted = user.Deleted;
                userDto.Role    = new RoleDto()
                {
                    RoleId = user.Role.RoleId, Name = user.Role.Name, Deleted = user.Role.Deleted
                };
                userDto.Person = new PersonDto()
                {
                    PersonId = user.Person.PersonId, Name = user.Person.Name, Deleted = user.Person.Deleted, BirthDay = user.Person.Birthday, LastName = user.Person.LastName, Gender = new GenderDto()
                    {
                        GenderId = user.Person.Gender.GenderId, Name = user.Person.Gender.Name
                    }, User = new UserDto()
                };
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(userDto);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get contact by id Dto
        /// </summary>
        /// <param name="id">Id contact to search</param>
        /// <returns>Return object contact</returns>
        public static ContactDto GetDto(int id, ModelUnibookContainer objContex)
        {
            ContactDto contactDto = null;

            try
            {
                Contact contact = Get(id, objContex);
                contactDto             = new ContactDto();
                contactDto.ContactId   = contact.ContactId;
                contactDto.Data        = contact.Data;
                contactDto.Description = contact.Description;
                contactDto.Deleted     = contact.Deleted;
                contactDto.Person      = PersonBrl.GetDto(contact.Person.PersonId, objContex);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(contactDto);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Get list person
        /// </summary>
        /// <param name="objContex">Get table to object</param>
        /// <returns></returns>
        public static List <CareerDto> Get(ModelUnibookContainer objContex)
        {
            try
            {
                List <CareerDto> careerList = new List <CareerDto>();
                foreach (var item in CareerListDal.Get(objContex))
                {
                    CareerDto career = new CareerDto()
                    {
                        Deleted  = item.Deleted,
                        Name     = item.Name,
                        CareerId = item.CareerId,
                        Faculty  = new FacultyDto()
                        {
                            FacultyId = item.Faculty.FacultyId, Name = item.Faculty.Name, Deleted = item.Faculty.Deleted
                        }
                    };

                    careerList.Add(career);
                }

                return(careerList);
            }
            catch (DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Get contact by id
        /// </summary>
        /// <param name="id">Id contact to search</param>
        /// <returns>Return object contact</returns>
        public static Contact Get(int id, ModelUnibookContainer objContex)
        {
            Contact contactReturn = null;

            try
            {
                bool exist = (from contact in objContex.Contact
                              where contact.Deleted == false && contact.ContactId == id
                              select contact).Count() > 0;
                if (exist)
                {
                    contactReturn = (from contact in objContex.Contact
                                     where contact.Deleted == false && contact.ContactId == id
                                     select contact).Single <Contact>();
                }
            }
            catch (DbEntityValidationException ex)
            {
                System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
                throw ex;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
                throw ex;
            }

            return(contactReturn);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get a user Career with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static UserCareerDto GetDto(int id, ModelUnibookContainer objContex)
        {
            UserCareerDto userCareerDto = null;

            try
            {
                UserCareer userCareer = UserCareerDal.Get(id, objContex);
                userCareerDto.UserCareerId             = userCareer.UserCareerId;
                userCareerDto.User                     = new UserDto();
                userCareerDto.User.UserId              = userCareer.User.UserId;
                userCareerDto.User.Email               = userCareer.User.Email;
                userCareerDto.User.Deleted             = userCareer.User.Deleted;
                userCareerDto.User.Password            = new PasswordDto();
                userCareerDto.User.Role                = new RoleDto();
                userCareerDto.User.Role.RoleId         = userCareer.User.Role.RoleId;
                userCareerDto.User.Role.Name           = userCareer.User.Role.Name;
                userCareerDto.User.Role.Deleted        = userCareer.User.Role.Deleted;
                userCareerDto.User.Person              = new PersonDto();
                userCareerDto.Career                   = new CareerDto();
                userCareerDto.Career.CareerId          = userCareer.Career.CareerId;
                userCareerDto.Career.Name              = userCareer.Career.Name;
                userCareerDto.Career.Deleted           = userCareer.Career.Deleted;
                userCareerDto.Career.Faculty           = new FacultyDto();
                userCareerDto.Career.Faculty.FacultyId = userCareer.Career.Faculty.FacultyId;
                userCareer.Career.Faculty.Name         = userCareer.Career.Faculty.Name;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(userCareerDto);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Deleted a faculty
 /// </summary>
 /// <param name="id"></param>
 /// <param name="objContex"></param>
 public static void Delete(int id, ModelUnibookContainer objContex)
 {
     try
     {
         FacultyDal.Delete(id, objContex);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Deleted a role
 /// </summary>
 /// <param name="id"></param>
 /// <param name="objContex"></param>
 public static void Delete(short id, ModelUnibookContainer objContex)
 {
     try
     {
         RoleDal.Delete(id, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Deleted a user
 /// </summary>
 /// <param name="id"></param>
 /// <param name="objContex"></param>
 public static void Delete(long id, ModelUnibookContainer objContex)
 {
     try
     {
         UserDal.Delete(id, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Update a user Career
 /// </summary>
 /// <param name="userCareer"></param>
 /// <param name="objContex"></param>
 public static void Update(UserCareer userCareer, ModelUnibookContainer objContex)
 {
     try
     {
         objContex.SaveChanges();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
         throw ex;
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Change password from user.
 /// </summary>
 /// <param name="userPassword">User password</param>
 /// <param name="objContext"></param>
 public static bool ChangePassword(PasswordDto userPassword, ModelUnibookContainer objContext)
 {
     try
     {
         objContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
         throw ex;
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Insert a faculty
 /// </summary>
 /// <param name="faculty"></param>
 /// <param name="objContex"></param>
 public static void Insert(Faculty faculty, ModelUnibookContainer objContex)
 {
     try
     {
         objContex.Faculty.Add(faculty);
         objContex.SaveChanges();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
         throw ex;
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Update changes in the context
 /// </summary>
 /// <param name="role"></param>
 /// <param name="objContex"></param>
 public static void Update(RoleDto roleDto, ModelUnibookContainer objContex)
 {
     try
     {
         Role role = RoleBrl.Get(roleDto.RoleId, objContex);;
         role.Name    = roleDto.Name;
         role.Deleted = roleDto.Deleted;
         RoleDal.Update(role, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Create a new faculty
 /// </summary>
 /// <param name="faculty"></param>
 /// <param name="objContex"></param>
 public static void Insert(FacultyDto facultyDto, ModelUnibookContainer objContex)
 {
     try
     {
         Faculty faculty = new Faculty();
         faculty.FacultyId = facultyDto.FacultyId;
         faculty.Name      = facultyDto.Name;
         faculty.Deleted   = facultyDto.Deleted;
         FacultyDal.Insert(faculty, objContex);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// Deleted a role
 /// </summary>
 /// <param name="id"></param>
 /// <param name="objContex"></param>
 public static void Delete(short id, ModelUnibookContainer objContex)
 {
     try
     {
         Role role = objContex.Role.Find(id);
         role.Deleted = true;
         objContex.SaveChanges();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(string.Format("{0} {1} Error: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ex.Message));
         throw ex;
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// Update changes in the context
 /// </summary>
 /// <param name="objContex"></param>
 public static void Update(FacultyDto facultyDto, ModelUnibookContainer objContex)
 {
     try
     {
         Faculty faculty = FacultyBrl.Get(facultyDto.FacultyId, objContex);
         faculty.Name    = faculty.Name;
         faculty.Deleted = faculty.Deleted;
         FacultyDal.Update(faculty, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// Update changes in the context
 /// </summary>
 /// <param name="role"></param>
 /// <param name="objContex"></param>
 public static void Update(UserDto userDto, ModelUnibookContainer objContex)
 {
     try
     {
         User user = UserBrl.Get(userDto.UserId, objContex);;
         user.Email   = userDto.Email;
         user.Deleted = userDto.Deleted;
         UserDal.Update(user, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Get a faculty with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static Faculty Get(int id, ModelUnibookContainer objContex)
        {
            Faculty faculty = null;

            try
            {
                faculty = FacultyDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(faculty);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Deleted a contact
 /// </summary>
 /// <param name="id">Id contact to deleted</param>
 /// <param name="objContex">Get table to object</param>
 public static void Delete(int id, ModelUnibookContainer objContex)
 {
     try
     {
         ContactDal.Delete(id, objContex);
     }
     catch (DbEntityValidationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Get a gender with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static Gender Get(int id, ModelUnibookContainer objContex)
        {
            Gender gender = null;

            try
            {
                gender = GenderDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(gender);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Get a user with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static User Get(long id, ModelUnibookContainer objContex)
        {
            User user = null;

            try
            {
                user = UserDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(user);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Get a career with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static Career Get(int id, ModelUnibookContainer objContex)
        {
            Career career = null;

            try
            {
                career = CareerDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(career);
        }
Exemplo n.º 28
0
 /// <summary>
 /// Update changes in the context
 /// </summary>
 /// <param name="career"></param>
 /// <param name="objContex"></param>
 public static void Update(CareerDto careerDto, ModelUnibookContainer objContex)
 {
     try
     {
         Career career = CareerBrl.Get(careerDto.CareerId, objContex);
         career.Name    = careerDto.Name;
         career.Deleted = careerDto.Deleted;
         career.Faculty = FacultyBrl.Get(careerDto.Faculty.FacultyId, objContex);
         CareerDal.Update(career, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// Create a new role
 /// </summary>
 /// <param name="role"></param>
 /// <param name="objContex"></param>
 public static void Insert(RoleDto roleDto, ModelUnibookContainer objContex)
 {
     try
     {
         Role role = new Role();
         role.Name    = roleDto.Name;
         role.RoleId  = roleDto.RoleId;
         role.Deleted = roleDto.Deleted;
         RoleDal.Insert(role, objContex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// Get a role with identifier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objContex"></param>
        /// <returns></returns>
        public static Role Get(short id, ModelUnibookContainer objContex)
        {
            Role role = null;

            try
            {
                role = RoleDal.Get(id, objContex);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(role);
        }