public void Map_UserGroupSave_To_IUserGroup() { var userModelMapper = new UserModelMapper(); Mapper.Initialize(configuration => userModelMapper.ConfigureMappings(configuration, ApplicationContext.Current)); var userService = ApplicationContext.Services.UserService; IUserGroup userGroup = new UserGroup(0, "alias", "name", new List <string> { "c" }, "icon"); userService.Save(userGroup); // userGroup.permissions is System.Collections.Generic.List`1[System.String] userGroup = userService.GetUserGroupById(userGroup.Id); // userGroup.permissions is System.Linq.Enumerable+WhereSelectArrayIterator`2[System.Char, System.String] // fixed: now System.Collections.Generic.List`1[System.String] const string json = "{\"id\":@@@ID@@@,\"alias\":\"perm1\",\"name\":\"Perm1\",\"icon\":\"icon-users\",\"sections\":[\"content\"],\"users\":[],\"defaultPermissions\":[\"F\",\"C\",\"A\"],\"assignedPermissions\":{},\"startContentId\":-1,\"startMediaId\":-1,\"action\":\"save\",\"parentId\":-1}"; var userGroupSave = JsonConvert.DeserializeObject <UserGroupSave>(json.Replace("@@@ID@@@", userGroup.Id.ToString())); // failed, AutoMapper complained, "Unable to cast object of type 'WhereSelectArrayIterator`2[System.Char,System.String]' to type 'System.Collections.IList'". // fixmed: added ToList() in UserGroupFactory Mapper.Map(userGroupSave, userGroup); }
public UserDbModel Login(UserDbModel dbModel) { using (DesarrolloDocenteBDEntities db = new DesarrolloDocenteBDEntities()) { var login = (from user in db.SEC_USER where user.EMAIL.ToUpper().Equals(dbModel.Email.ToUpper()) && user.USER_PASSWORD.Equals(dbModel.Password) select user).FirstOrDefault(); if (login == null) { return(null); } var date = dbModel.CurrentDate; SEC_SESSION session = new SEC_SESSION() { USERID = login.ID, LOGIN_DATE = date, TOKEN_STATUS = true, TOKEN = this.GetToken(String.Concat(login.ID, date)), IP_ADDRESS = this.GetIpAddress() }; db.SEC_SESSION.Add(session); db.SaveChanges(); UserModelMapper mapper = new UserModelMapper(); return(mapper.MapperT1T2(login)); } }
public async Task <UserDto> GetOneUserAsync(string id) { _logger.LogMessage("Retrieved a user from db."); UserDb userdb = await _dbmanager.GetUserAsync(id); UserDto userdto = UserModelMapper.UserDbToDtoModel(userdb); return(userdto); }
public async Task UpdateExistingUserAsync(string id, string person) { var userDto = _parsingManager.ParseData(person); UserDb userdb = UserModelMapper.UserDtoToDbModel(userDto); await _dbmanager.UpdateUserAsync(id, userdb); _logger.LogMessage("Updated a user in db."); }
public async Task SaveNewPersonAsync(string person) { var userDto = _parsingManager.ParseData(incomingData: person); UserDb userdb = UserModelMapper.UserDtoToDbModel(userDto); await _dbmanager.InsertUserAsync(userdb); _logger.LogMessage("Saved a user to db."); // if this is not here, the test should fail }
public static async Task <DbUserModel> GetUserFromGuid(string guid) { UserModelMapper user = (await MongoConnector.GetUserCollection() .FindAsync(it => it.Id == guid)) .FirstOrDefault(); if (user == null) { return(null); } return(new DbUserModel(user.ToProto())); }
/// <summary> /// /// </summary> /// <param name="filter"></param> /// <returns></returns> public IEnumerable <UserDbModel> RecordList(string filter) { using (DesarrolloDocenteBDEntities db = new DesarrolloDocenteBDEntities()) { var lista = from role in db.SEC_USER where !role.REMOVED && role.NAME.ToUpper().Contains(filter.ToUpper()) select role; UserModelMapper mapper = new UserModelMapper(); var listaFinal = mapper.MapperT1T2(lista); return(listaFinal); } }
/// <summary> /// Se agrega un nuevo registro a los roles /// </summary> /// <param name="dbModel">Representa un objeto con la información del rol</param> /// <returns>entero con la respuesta: 1. OK, 2. KO, 3. Ya existe</returns> public int RecordCreation(UserDbModel dbModel) { using (DesarrolloDocenteBDEntities db = new DesarrolloDocenteBDEntities()) { try { UserModelMapper mapper = new UserModelMapper(); SEC_USER record = mapper.MapperT2T1(dbModel); record.CREATE_DATE = dbModel.CurrentDate; record.CREATE_USER_ID = dbModel.UserInSessionId; db.SEC_USER.Add(record); db.SaveChanges(); return(1); } catch { return(2); } } }