예제 #1
0
 public HttpResponseMessage GetAll()
 {
     try
     {
         LoggerUtils.WriteLog("MachinesController : GET ALL - request received");
         var machines = machineService.GetAll();
         return(Request.CreateResponse(HttpStatusCode.OK, machines));
     }
     catch (Exception ex)
     {
         LoggerUtils.WriteLog("ERROR : MachinesController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
예제 #2
0
 /// <summary>
 /// First Project
 /// </summary>
 static void Main()
 {
     using (var context = new MesDbContext())
     {
         // Create database
         context.Database.EnsureCreated();
         MachineRepository repository = new MachineRepository(context);
         UnitOfWork        untiWork   = new UnitOfWork(context);
         var machineService           = new MachineService(untiWork, repository);
         machineService.Create(new Machine()
         {
             Code = "xxx"
         });
         foreach (var machine in machineService.GetAll())
         {
             Console.WriteLine(machine.Code);
         }
     }
     Console.ReadLine();
 }