Exemplo n.º 1
0
        /// <summary>
        /// category update
        /// </summary>
        /// <param name="id"></param>
        /// <param name="idCategory"></param>
        /// <returns></returns>
        public static BO.TodoCategoryItem Category(int id, int idCategory)
        {
            BO.TodoCategoryItem result = new BO.TodoCategoryItem();

            //eseguo la query sul DB
            using (SqlConnection cnn = GetConnection())
            {
                using (SqlCommand cmd = cnn.CreateCommand())
                {
                    cmd.CommandText = queries.UpdateCategory;
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value         = id;
                    cmd.Parameters.Add("@idCategory", SqlDbType.Int).Value = idCategory;
                    cnn.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        if (dr.Read())
                        {
                            result.ID         = (int)dr["ID"];
                            result.IDCategory = (int)dr["IDCategory"];
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public BO.ServiceStatus <BO.TodoCategoryItem> Category([FromBody] BO.TodoCategoryItem param)
        {
            BO.ServiceStatus <BO.TodoCategoryItem> result = new BO.ServiceStatus <BO.TodoCategoryItem>();
            try
            {
                //controllo presenza parametri
                if (param.ID == 0)
                {
                    result.AddError("`id` in required");
                }

                if (result.Messages.Count == 0)
                {
                    result.Data = Code.Manager.Category(param.ID, param.IDCategory);
                    //result.AddSuccess("Category updated id: " + param.ID.ToString());
                    result.Success = true;
                }
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }