public void ListAllDptTest()
 {
     var ops = new DepartmentOperations();
     var response = ops.ListAllDepartments();
     Assert.IsTrue(response.Success);
     Assert.AreEqual(8,response.Data.Count);
 }
 public void GetSingleDptTest()
 {
     var ops = new DepartmentOperations();
     var response = ops.GetSingleDpt(5);
     Assert.IsTrue(response.Success);
     Assert.AreEqual("Human Resources", response.Data.DepartmentName);
 }
 public void CreateDptTest()
 {
     var ops = new DepartmentOperations();
     ops.CreateDepartment("Customer Service");
     var ptoList = ops.ListAllDepartments();
     var newDpt = ptoList.Data.FirstOrDefault(x => x.DepartmentID == 8);
     Assert.AreEqual("Customer Service", newDpt.DepartmentName);
 }
Esempio n. 4
0
        // GET api/<controller>
        public List<Departments> Get()
        {
            var ops = new DepartmentOperations();
            var response = ops.ListAllDepartments();
            var list = response.Data;
            return list;

        }
 public List<SelectListItem> GenerateDepartmentList()
 {
     var ops = new DepartmentOperations();
     var response = ops.ListAllDepartments();
     var listDpt = response.Data;
     var dptVM = new DepartmentsVM();
     dptVM.GenerateListOfDpts(listDpt);
     List<SelectListItem> dptSelectListItem = dptVM.DepartmentNames;
     return dptSelectListItem;
 }
Esempio n. 6
0
        // POST api/<controller>

        public HttpResponseMessage Post(Departments department)
        {

            var ops = new DepartmentOperations();
            ops.CreateDepartment(department.DepartmentName);
            var opsResponse = ops.GetDptIdByName(department.DepartmentName);
            int dptId = opsResponse.Data;

            var response = Request.CreateResponse(HttpStatusCode.Created, department.DepartmentName);

            string uri = Url.Link("DefaultApi", new { id = dptId });
            response.Headers.Location = new Uri(uri);

            return response;


        }
Esempio n. 7
0
 // DELETE api/<controller>/5
 public void Delete(int id)
 {
     var ops = new DepartmentOperations();
     ops.DeleteDepartment(id);
 }
Esempio n. 8
0
 // PUT api/<controller>/5
 public void Put(Departments department)
 {
     var ops = new DepartmentOperations();
     ops.UpdateDepartment(department);
 }