示例#1
0
        public BO.ServiceStatus Delete([FromBody] BO.TodoItem param)
        {
            BO.ServiceStatus result = new Models.BO.ServiceStatus();
            try
            {
                //controllo presenza parametri
                int id = param.ID;
                if (id == 0)
                {
                    result.AddError("`id` in required");
                }

                if (result.Messages.Count == 0)
                {
                    int r = Code.Manager.Delete(id);
                    if (r == 0)
                    {
                        result.AddError("Error: not deleted");
                    }
                    else
                    {
                        result.AddSuccess("Deleted id: " + id.ToString());
                        result.Success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }
示例#2
0
        public BO.ServiceStatus Updarte([FromBody] BO.TodoItem param)
        {
            BO.ServiceStatus result = new Models.BO.ServiceStatus();
            try
            {
                //controllo presenza parametri
                if (param.ID == 0)
                {
                    result.AddError("`id` in required");
                }
                //if (!req.body.hasOwnProperty('date')) result.addError('`date` required');
                if (string.IsNullOrWhiteSpace(param.Title))
                {
                    result.AddError("`title` required");
                }
                if (param.IDCategory == 0)
                {
                    result.AddError("`idCategory` required");
                }

                if (result.Messages.Count == 0)
                {
                    int      id         = param.ID;
                    DateTime date       = param.Date;
                    string   title      = param.Title;
                    int      idCategory = param.IDCategory;
                    string   note       = param.Note;
                    DateTime?completed  = param.Completed;
                    int      r          = Code.Manager.Update(id, date, title, note, idCategory, completed);
                    if (r == 0)
                    {
                        result.AddError("Error: not updated");
                    }
                    else
                    {
                        result.AddSuccess("Updated: " + 1);
                        result.Success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }