public async Task <ServiceStatus> MyTaskDeleteAsync(MyTaskInput inputData) { ServiceStatus result = new ServiceStatus(); try { if (inputData.ID.HasValue == false || inputData.ID == 0) { result.AddError("`id` required"); } if (result.Messages.Count > 0) { return(result); } result.ReturnValue = _manager.TaskDelete(inputData.ID.Value); if (result.ReturnValue > 0) { result.AddSuccess($"Deleted"); } else { result.AddWarning("No change"); } result.Success = true; } catch (Exception ex) { result.AddError(ex); } return(result); }
public async Task <ServiceStatus> MyTaskUpdateAsync(MyTaskInput inputData) { ServiceStatus result = new ServiceStatus(); try { if (inputData.ID.HasValue == false || inputData.ID == 0) { result.AddError("`id` required"); } if (inputData.Date.HasValue == false || inputData.Date < new DateTime(1970, 1, 1)) { result.AddError("`date` required"); } if (string.IsNullOrWhiteSpace(inputData.Title)) { result.AddError("`title` required"); } if (inputData.IDCategory == null || inputData.IDCategory < 1) { result.AddError("`category` required"); } if (result.Messages.Count > 0) { return(result); } DateTime dtNow = DateTime.Now; MyTask item = new MyTask { Date = inputData.Date.Value, Title = inputData.Title, Note = string.IsNullOrWhiteSpace(inputData.Note) ? null : inputData.Note, Category = new Category { ID = inputData.IDCategory.Value }, Completed = inputData.Completed, Created = dtNow, Modified = dtNow }; result.ReturnValue = _manager.TaskAdd(item); if (result.ReturnValue > 0) { result.AddSuccess($"Readed 1"); } else { result.AddWarning("No change"); } result.Success = true; } catch (Exception ex) { result.AddError(ex); } return(result); }