///<summary> ///Maps properties from EntityORM object to UseConnectionrDb object ///</summary> public static void Map(EntityORM entity, out UsersConnectionDb userConnection) { userConnection = new UsersConnectionDb(); foreach (KeyValuePair <string, object> aV in entity.attributeValue) { switch (aV.Key) // attribute { case "ID": userConnection.Id = Convert.ToInt64(aV.Value); break; case "IDUSER1": userConnection.IdUser1 = Convert.ToInt64(aV.Value); break; case "IDUSER2": userConnection.IdUser2 = Convert.ToInt64(aV.Value); break; case "AREFRIENDS": userConnection.AreFriends = DbTools.ProcessBoolean(aV.Value); break; case "BLACKLISTED": userConnection.BlackListed = DbTools.ProcessBoolean(aV.Value); break; default: break; } } }
public bool CreateConnection(UsersConnectionDb usersConnection) { if (ConnectionExists(usersConnection)) { return(false); } bool isCreated = false; UsersConnectionDb symmetricConnection = new UsersConnectionDb() { IdUser1 = usersConnection.IdUser2, IdUser2 = usersConnection.IdUser1 }; var where_attributes = new Dictionary <string, object>() { { "IDUSER1", symmetricConnection.IdUser1 }, { "IDUSER2", symmetricConnection.IdUser2 } }; EntityORM entity = Get(table, attributes, where_attributes); if (entity != null) { if (DbTools.ProcessBoolean(entity.attributeValue["BLACKLISTED"])) { return(isCreated); } symmetricConnection.AreFriends = true; EntityORM symmetricConnection_newTyped = Mapping.EntityMapping.Map(symmetricConnection, attributes); // Making sure that ID value is not touched. symmetricConnection_newTyped.attributeValue.Remove("ID"); Update(table, attributes, where_attributes, symmetricConnection_newTyped); usersConnection.AreFriends = true; } isCreated = Save(usersConnection); return(isCreated); }
///<summary> ///Maps properties from EntityORM object to GameDb object ///</summary> public static void Map(EntityORM entity, out GameDb game) { game = new GameDb(); foreach (KeyValuePair <string, object> aV in entity.attributeValue) { switch (aV.Key) // entity attribute { case "ID": game.Id = Convert.ToInt64(aV.Value); break; case "NAME": game.Name = aV.Value.ToString(); break; case "DESCRIPTION": game.Description = aV.Value.ToString(); break; case "GENRE": game.Genre = aV.Value.ToString(); break; case "LINK": game.Link = aV.Value.ToString(); break; case "LOGOURL": game.LogoURL = aV.Value.ToString(); break; case "COVERURL": game.CoverURL = aV.Value.ToString(); break; case "ISVERIFIED": game.IsVerified = DbTools.ProcessBoolean(aV.Value); break; default: break; } } }
///<summary> ///Maps properties from EntityORM object to MessageDb object ///</summary> public static void Map(EntityORM entity, out MessageDb message) { message = new MessageDb(); foreach (KeyValuePair <string, object> aV in entity.attributeValue) { switch (aV.Key) // entity attribute { case "ID": message.Id = Convert.ToInt64(aV.Value); break; case "IDSENDER": message.IdSender = Convert.ToInt64(aV.Value); break; case "IDCHAT": message.IdChat = Convert.ToInt64(aV.Value); break; case "CONTENT": message.Content = aV.Value.ToString(); break; case "CREATEDATE": message.CreateDate = (DateTime)aV.Value; break; case "ISREAD": message.IsRead = DbTools.ProcessBoolean(aV.Value); break; default: break; } } }
///<summary> ///Maps properties from EntityORM object to UserDb object ///</summary> public static void Map(EntityORM entity, out UserDb user) { user = new UserDb(); foreach (KeyValuePair <string, object> aV in entity.attributeValue) { switch (aV.Key) // attribute { case "ID": user.Id = Convert.ToInt64(aV.Value); break; case "NAME": user.Name = aV.Value.ToString(); break; case "NICKNAME": user.Nickname = aV.Value.ToString(); break; case "EMAIL": user.Email = aV.Value.ToString(); break; case "PASSWORD": user.Password = aV.Value.ToString(); break; case "PHOTOURL": user.PhotoURL = aV.Value.ToString(); break; case "ISVERIFIED": user.IsVerified = DbTools.ProcessBoolean(aV.Value); break; case "ISCREATOR": user.IsCreator = DbTools.ProcessBoolean(aV.Value); break; case "ISBANNED": user.IsBanned = DbTools.ProcessBoolean(aV.Value); break; case "DESCRIPTION": user.Description = aV.Value.ToString(); break; case "ENDBANDATE": user.EndBanDate = (DateTime)aV.Value; break; case "PLATFORMLANGUAGE": user.PlatformLanguage = aV.Value.ToString(); break; case "PLATFORMTHEME": user.PlatformTheme = aV.Value.ToString(); break; default: break; } } }