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)); } }
/// <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(); }