/// <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); }
/// <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; } }
/// <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); }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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); }
/// <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); }
/// <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; } }
/// <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); }
/// <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); }
/// <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) { } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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) { } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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); }
/// <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; } }
/// <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); }
/// <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); }
/// <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); }
/// <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; } }
/// <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; } }
/// <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); }