Exemple #1
0
        public long Update(Books_DTO obj)
        {
            long toReturn = 0;

            using (var sqlConnection = CoreConnection.GetConnection())
            {
                try
                {
                    toReturn = sqlConnection.Execute("update books set name = @name, pages = @pages, quantity = @quantity, update_date = (select getdate()) where id = @id", obj);
                }
                catch (Exception ex)
                {
                    message = CoreException.GetMessage(ex.Message);
                }


                if (toReturn > 0)
                {
                    message = "Cadastro realizado com sucesso";
                }

                return(toReturn);
            }
        }
Exemple #2
0
        public long Create(Books_DTO obj)
        {
            using (var sqlConnection = CoreConnection.GetConnection())
            {
                long toReturn = 0;

                try
                {
                    toReturn = sqlConnection.Execute("Insert into books (name, pages, create_date, update_date,author, quantity) values (@name, @pages, (select getdate()),(select getdate()),@author,@quantity  )", obj);
                }
                catch (Exception ex)
                {
                    message = CoreException.GetMessage(ex.Message);
                }


                if (toReturn > 0)
                {
                    message = "Cadastro realizado com sucesso";
                }

                return(toReturn);
            }
        }