static void Main(string[] args) { // test DataAccess { foreach (var item in PhanQuyenRepository.GetInstance().GetAll()) { Console.WriteLine(item.TenPhanQuyen); } } // test DataService { // Get //var result = new HttpClient().GetAsync("http://localhost:29370/hcm/nhanvien/getall").Result; //Console.Write(result.Content.ReadAsStringAsync().Result); // Post //var test = new NhanVien(); //var result = new HttpClient().PostAsync("http://localhost:29370/hcm/nhanvien/insert", new StringContent(JsonConvert.SerializeObject(test), Encoding.UTF8, "application/json")).Result; //Console.Write(result.Content.ReadAsStringAsync().Result); // Put //var test = new NhanVien(); //var result = new HttpClient().PutAsync("http://localhost:29370/hcm/nhanvien/update", new StringContent(JsonConvert.SerializeObject(test), Encoding.UTF8, "application/json")).Result; //Console.Write(result.Content.ReadAsStringAsync().Result); // Delete //var result = new HttpClient().DeleteAsync("http://...").Result; //Console.Write(result.Content.ReadAsStringAsync().Result); } // pause Console.Read(); }
public ChucVuBusiness() { _dbContext = new SMSEntities(); _chucVuRepo = new ChucVuRepository(_dbContext); _nhanVienQuyenRepo = new NhanVien_QuyenRepository(_dbContext); _phanQuyenRepo = new PhanQuyenRepository(_dbContext); _nhanVienRepo = new NhanVienRepository(_dbContext); }
public HttpResponseMessage GetAll(string id) { try { return(Request.CreateResponse(HttpStatusCode.OK, PhanQuyenRepository.GetInstance().GetFrom(id))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }