private tb_user ToDbModel(UserModel user) { tb_user tbUser = new tb_user(); tbUser.id_user = user.Id; tbUser.ds_email = user.Email; tbUser.ds_password = user.Password; tbUser.ds_name = user.Name; tbUser.ds_lastname = user.LastName; tbUser.id_identification = user.Identification; tbUser.vl_gmt = user.Gmt; tbUser.tb_sector_id_sector = 1; //TODO: Trocar o 1 para referencia da tabela setor if (user.Configuration != null) tbUser.tb_configuration_id_configuration = user.Configuration.Id; foreach (AccessLevelModel accessLevel in user.AccessLevel) tbUser.tb_access_level.Add(new AccessLevelService().ToDbModel(accessLevel)); return tbUser; }
public UserModel ToModel(tb_user tbUser) { UserModel user = new UserModel(); user.Id = tbUser.id_user; user.Email = tbUser.ds_email; //user.Password = tbUser.ds_password; user.Name = tbUser.ds_name; user.LastName = tbUser.ds_lastname; if(tbUser.vl_gmt != null) user.Gmt = (int)tbUser.vl_gmt; if (tbUser.tb_company != null) user.Company = new CompanyService().ToModel(tbUser.tb_company); if (tbUser.id_identification != null) user.Identification = (int)tbUser.id_identification; if (tbUser.tb_configuration != null) user.Configuration = new ConfigurationService().ToModel(tbUser.tb_configuration); foreach (tb_access_level accessLevel in tbUser.tb_access_level) user.AccessLevel.Add(new AccessLevelService().ToModel(accessLevel)); return user; }