public async System.Threading.Tasks.Task <ActionResult> EditDepartment(String id)
        {
            var model = new IndexDepartment();

            model.department = await ApiService.GetDepartment(id);

            return(View(model));
        }
        public async System.Threading.Tasks.Task <ActionResult> Index()
        {
            var model = new IndexDepartment();

            model.departments = await ApiService.GetAllDepartment();

            return(View(model));
        }
        public async System.Threading.Tasks.Task <ActionResult> EditDepartment(String id, Department department)
        {
            var model = new IndexDepartment();

            if (ModelState.IsValid)
            {
                model.departments = await ApiService.PutDepartmentsAsync(id, department);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async System.Threading.Tasks.Task <ActionResult> CreateDepartment(Department department)
        {
            var model = new IndexDepartment();

            if (ModelState.IsValid)
            {
                model.departments = await ApiService.PostDepartmentAsync(department);

                return(RedirectToAction("Index"));
            }
            return(View(model));
            // var model = new IndexModel();
        }
        public async System.Threading.Tasks.Task <ActionResult> DeleteDepartment(String id)
        {
            var model = new IndexDepartment();

            model.department = await ApiService.GetDepartment(id);

            if (model.department != null)
            {
                try
                {
                    model.departments = await ApiService.DeleteDepartmentAsync(id);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ViewBag.enrror = "Khong the xoa duoc!";
                    return(RedirectToAction("Index"));
                }
            }
            return(RedirectToAction("Index"));
        }