コード例 #1
0
ファイル: ChatDAO.cs プロジェクト: vanmxpx/ISDPlatform
        /// <summary>
        /// Return the ChatDb object with interop properties
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ChatDb GetExtended(long id)
        {
            ChatDb chat = Get(id);

            //chat.PlayersList = GetPlayersList(id);

            return(chat);
        }
コード例 #2
0
ファイル: ChatDAO.cs プロジェクト: vanmxpx/ISDPlatform
        // Here they will be

        #endregion

        #endregion

        public long Save(ChatDb chat)
        {
            EntityORM entity = EntityMapping.Map(chat, attributes);

            // Making sure that ID value is not touched.
            entity.attributeValue.Remove("ID");

            long idChat = crud.Create(table, idColumn, entity);

            return(idChat);
        }
コード例 #3
0
        public Chat Get(long id)
        {
            ChatDb chat          = chatDAO.GetExtended(id);
            Chat   chat_newTyped = null;

            if (chat != null)
            {
                chat_newTyped = mapper.Map(chat);
            }

            return(chat_newTyped);
        }
コード例 #4
0
ファイル: ChatDAO.cs プロジェクト: vanmxpx/ISDPlatform
        public ChatDb Get(long id)
        {
            ChatDb chat = null;

            List <EntityORM> entities = (List <EntityORM>)(crud.Read(table, attributes, new DbTools.WhereRequest[] { new DbTools.WhereRequest(idColumn, DbTools.RequestOperator.Equal, id) }));

            if (entities.Any())
            {
                EntityMapping.Map(entities[0], out chat);
            }

            return(chat);
        }
コード例 #5
0
        public ChatDb Get(long id)
        {
            ChatDb chat = null;

            EntityORM entity = crud.Read(id, idColumn, attributes, table);

            if (entity != null)
            {
                EntityMapping.Map(entity, out chat);
            }

            return(chat);
        }
コード例 #6
0
 //
 // ExibirChat
 //
 private void ExibirChat()
 {
     try
     {
         ErroOcultar();
         chatRepeater.DataSource = ChatDb.UltimasMensagens();
         chatRepeater.DataBind();
         MultiView1.ActiveViewIndex = 1;
     }
     catch (Exception ex)
     {
         ErroExibir(ex.Message);
     }
 }
コード例 #7
0
ファイル: ChatDAO.cs プロジェクト: vanmxpx/ISDPlatform
        public void Update(ChatDb chat)
        {
            EntityORM entity = EntityMapping.Map(chat, attributes);

            entity.attributeValue.Remove("ID");     // getting sure that ID value is not touched

            bool ifUpdated = crud.Update(chat.Id, table, idColumn, entity);

            if (ifUpdated)
            {
                logger.Info($"Game with id={chat.Id} was successfully updated.");
            }
            else
            {
                logger.Info($"Updating chat with id={chat.Id} was failed.");
            }
        }
コード例 #8
0
 // Entrar
 //
 protected void entrarButton_Click(object sender, EventArgs e)
 {
     try
     {
         ErroOcultar();
         string nome = nomeTextBox.Text;
         ChatDb.Entrar(nome);
         ViewState["nome"] = nome;
         ExibirChat();
         mensagemTextBox.Focus();
         mensagemTextBox.Text = string.Empty;
     }
     catch (Exception ex)
     {
         ErroExibir(ex.Message);
     }
 }
コード例 #9
0
ファイル: ModelsMapper.cs プロジェクト: vanmxpx/ISDPlatform
        public ChatDb Map(Chat chat)
        {
            ChatDb chat_newType = new ChatDb();

            #region Transfer main attributes

            chat_newType.Id       = chat.Id;
            chat_newType.ChatName = chat.ChatName;

            #endregion

            #region Transfering interop attributes
            //EMPTY

            #endregion

            return(chat_newType);
        }
コード例 #10
0
        //
        // Enviar mensagem
        //
        protected void enviarMensagemButton_Click(
            object sender, EventArgs e)
        {
            string nome     = (string)ViewState["nome"];
            string mensagem = mensagemTextBox.Text;

            try
            {
                ErroOcultar();
                ChatDb.EnviarMensagem(nome, mensagem);
                ExibirChat();
                mensagemTextBox.Focus();
                mensagemTextBox.Text = string.Empty;
            }
            catch (Exception ex)
            {
                ErroExibir(ex.Message);
            }
        }
コード例 #11
0
        ///<summary>
        ///Maps properties from EntityORM object to ChatDb object
        ///</summary>
        public static void Map(EntityORM entity, out ChatDb chat)
        {
            chat = new ChatDb();

            foreach (KeyValuePair <string, object> aV in entity.attributeValue)
            {
                switch (aV.Key)  // entity attribute
                {
                case "ID":
                    chat.Id = Convert.ToInt64(aV.Value);
                    break;

                case "CHATNAME":
                    chat.ChatName = aV.Value.ToString();
                    break;

                default:
                    break;
                }
            }
        }
コード例 #12
0
        ///<summary>
        ///Maps properties from ChatDb object to EntityORM object
        ///</summary>
        public static EntityORM Map(ChatDb chat, HashSet <string> attributes)
        {
            EntityORM entity = new EntityORM();

            foreach (string attribute in attributes)
            {
                object value = null;        // attribute value

                switch (attribute)
                {
                case "CHATNAME":
                    value = $"\'{chat.ChatName}\'";
                    break;

                default:
                    break;
                }

                entity.attributeValue.Add(attribute, value);
            }

            return(entity);
        }
コード例 #13
0
        public void Update(Chat chat)
        {
            ChatDb chatDb = mapper.Map(chat);

            chatDAO.Update(chatDb);
        }
コード例 #14
0
        public long Create(Chat chat)
        {
            ChatDb chatDb = mapper.Map(chat);

            return(chatDAO.Save(chatDb));
        }
コード例 #15
0
 public ChatBLL(ChatDb chatDb, IUserContextAccessor userContextAccessor)
 {
     _userInfo = userContextAccessor.UserContext.UserInfo;
     _chatDb   = chatDb;
 }