/// <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> /// Create a new user /// </summary> /// <param name="role"></param> /// <param name="objContex"></param> public static void Insert(UserDto userDto, ModelUnibookContainer objContex) { try { User user = new User(); user.Email = userDto.Email; user.Role = RoleBrl.Get(userDto.Role.RoleId, objContex); user.Person = PersonBrl.Get(userDto.Person.PersonId, objContex); user.Deleted = userDto.Deleted; PasswordDto password = userDto.Password; UserDal.Insert(user, password, objContex); } catch (Exception ex) { throw ex; } }
/// <summary> /// Insert a contact /// </summary> /// <param name="contact">Object contact to insert</param> /// <param name="objContex">Get table to object</param> public static void Insert(ContactDto contactDto, ModelUnibookContainer objContex) { try { Contact contact = new Contact(); contact.ContactId = contactDto.ContactId; contact.Data = contactDto.Data; contact.Description = contactDto.Description; contact.Person = PersonBrl.Get(contactDto.Person.PersonId, objContex); ContactDal.Insert(contact, objContex); } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Update a contact /// </summary> /// <param name="objContex">Get table to object</param> public static void Update(ContactDto contactDto, ModelUnibookContainer objContex) { try { Contact contact = ContactDal.Get(contactDto.ContactId, objContex); contact.Data = contactDto.Data; contact.Description = contactDto.Description; contact.Deleted = contactDto.Deleted; contact.Person = PersonBrl.Get(contactDto.Person.PersonId, objContex); ContactDal.Update(objContex); } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Get list person /// </summary> /// <param name="objContex">Get table to object</param> /// <returns></returns> public static List <PersonDto> Get(ModelUnibookContainer objContex) { try { List <PersonDto> personList = new List <PersonDto>(); foreach (var item in PersonListDal.Get(objContex)) { personList.Add(PersonBrl.GetDto(item.PersonId, objContex)); } return(personList); } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }