Example #1
0
        public void ListAllDptTest()
        {
            var ops      = new DepartmentOperations();
            var response = ops.ListAllDepartments();

            Assert.IsTrue(response.Success);
            Assert.AreEqual(8, response.Data.Count);
        }
Example #2
0
        public void GetSingleDptTest()
        {
            var ops      = new DepartmentOperations();
            var response = ops.GetSingleDpt(5);

            Assert.IsTrue(response.Success);
            Assert.AreEqual("Human Resources", response.Data.DepartmentName);
        }
Example #3
0
        // GET api/<controller>
        public List <Departments> Get()
        {
            var ops      = new DepartmentOperations();
            var response = ops.ListAllDepartments();
            var list     = response.Data;

            return(list);
        }
Example #4
0
        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);
        }
        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);
        }
Example #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);
        }
Example #7
0
        // DELETE api/<controller>/5
        public void Delete(int id)
        {
            var ops = new DepartmentOperations();

            ops.DeleteDepartment(id);
        }
Example #8
0
        // PUT api/<controller>/5
        public void Put(Departments department)
        {
            var ops = new DepartmentOperations();

            ops.UpdateDepartment(department);
        }