csharp CarService.cs

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp CarService.cs相关的知识,希望对你有一定的参考价值。

public class CarService
{
  private CarRepository carRepo = new CarRepository();
  public ServiceActionResult<Car> GetCar(int id)
  {
    try
    {
      var car = carRepo.GetCar(id);
      if(car == null)
        return new ServiceActionResult<Car>(null, ServiceActionStatus.NotFound);
      return new ServiceActionResult<Car>(car,ServiceActionStatus.Ok);     
    }
    catch(Exception ex)
    {
      return new ServiceActionResult<Car>(null,ServiceActionStatus.Error, ex);
    }
  }
  
  public ServiceActionResult<Car> CreateCar(Car car)
  {
    try
    {
      var success = carRepo.CreateCar(car);
      if(success)
        return new ServiceActionResult<Car>(car, ServiceActionStatus.Created);
      return new ServiceActionResult<Car>(car, ServiceActionStatus.NothingModified);
    }
    catch(Exception ex)
    {
      return new ServiceActionResult<Car>(null,ServiceActionStatus.Error, ex);
    }
  }
}

以上是关于csharp CarService.cs的主要内容,如果未能解决你的问题,请参考以下文章

csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp - 程序 - ConvertFilesToDifferentFormats.cs

csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp渲染,RenderPSDImageAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 例如-CSHARP-GroupDocs.Search.Examples.CSharp索引,AddDocumentToIndex.cs