本文整理汇总了C#中ApiResponse.Failed方法的典型用法代码示例。如果您正苦于以下问题:C# ApiResponse.Failed方法的具体用法?C# ApiResponse.Failed怎么用?C# ApiResponse.Failed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiResponse
的用法示例。
在下文中一共展示了ApiResponse.Failed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
public ApiResponse<ItemType> Insert(ItemType model)
{
var result = new ApiResponse<ItemType>();
if (model == null || string.IsNullOrEmpty(model.Text) || model.Subject_Id == 0)
{
return result.Failed(ResultEnum.ParameterError);
}
if (ItemTypeRepository.LoadEntities(x => x.Text == model.Text).Any())
{
return result.Failed(ResultEnum.FormatError, "存在Text相同的数据");
}
model.Text = model.Text.Trim();
result.Result = ItemTypeRepository.Insert(model);
if (model.Id > 0) { result.Success(); }
return result;
}
示例2: Remove
public ApiResponse<bool> Remove(int id)
{
var result = new ApiResponse<bool>();
var entity = ItemTypeRepository.LoadEntities(x => x.Id == id).FirstOrDefault();
if (entity == null)
{
return result.Failed(ResultEnum.NoData);
}
result.Result = ItemTypeRepository.Remove(entity);
if (result.Result) { result.Success(); }
return result;
}
示例3: Update
public ApiResponse<bool> Update(ItemType model)
{
var result = new ApiResponse<bool>();
var entity = ItemTypeRepository.LoadEntities(x => x.Id == model.Id).FirstOrDefault();
if (entity == null)
{
return result.Failed(ResultEnum.ParameterError);
}
entity.Text = model.Text.Trim();
entity.Subject_Id = model.Subject_Id;
result.Result = ItemTypeRepository.Update(entity);
if (result.Result) { result.Success(); }
return result;
}
示例4: FindList
public ApiResponse<List<ExamItem>> FindList(FindListRequest request)
{
var model = ExamItemService.GetEntitiesByIds(request.Ids);
var result = new ApiResponse<List<ExamItem>>()
{
Result = model
};
if (model != null)
{
result.Success();
}
else
{
result.Failed(ResultEnum.NoData);
}
return result;
}
示例5: Find
public ApiResponse<ExamItem> Find(int id)
{
var model = ExamItemService.GetEntityById(id);
var result = new ApiResponse<ExamItem>()
{
Result = model
};
if (model != null)
{
result.Success();
}
else
{
result.Failed(ResultEnum.NoData);
}
return result;
}