public HttpResponseMessage GetFPMachine(string name) { FPMachineRepository fPMachineRepository = new FPMachineRepository(new Domain.Staff.ErpStaffDbContext()); var fPMachine = fPMachineRepository.GetAllFPMachine() .Where(item => item.Ten_may_tinh == name).FirstOrDefault(); if (fPMachine == null) { fPMachine = new FPMachine(); fPMachine.IsDeleted = false; fPMachine.CreatedDate = DateTime.Now; fPMachine.ModifiedDate = DateTime.Now; fPMachine.UpdatedDate = DateTime.Now; fPMachine.Ten_may_tinh = name; fPMachine.Dia_chi_IP = "192.168.1.201"; fPMachine.Toc_do_truyen = "115200"; fPMachine.Port = 4370; fPMachine.GetDataSchedule = "19:00"; fPMachine.useurl = false; fPMachineRepository.InsertFPMachine(fPMachine); } else { fPMachine.UpdatedDate = DateTime.Now; fPMachineRepository.UpdateFPMachine(fPMachine); } var res = Request.CreateResponse(HttpStatusCode.OK, fPMachine); return(res); }
public HttpResponseMessage GetFPMachineList() { FPMachineRepository fPMachineRepository = new FPMachineRepository(new Domain.Staff.ErpStaffDbContext()); var q = fPMachineRepository.GetAllFPMachine(); var res = Request.CreateResponse(HttpStatusCode.OK, q.ToList()); return(res); }