// GET: Department
        public ActionResult Index()
        {
            DepartmentClient  departmentClient = new DepartmentClient();
            List <Department> departments      = departmentClient.findAll().ToList();

            return(View(departments));
        }
        public ActionResult Delete(int id)
        {
            DepartmentClient departmentClient = new DepartmentClient();
            Department       department       = departmentClient.find(id);

            return(View("Edit", department));
        }
        public ActionResult Create(Department department)
        {
            DepartmentClient departmentClient = new DepartmentClient();

            departmentClient.Create(department);
            return(RedirectToAction("Index"));
        }
        public void PopulateDepartmentsDropDownList(DepartmentClient departmentClient,
                                                    object selectedDepartment = null)
        {
            var departmentsQuery = departmentClient.SearchAsync().Result;

            DepartmentNameSL = new SelectList(departmentsQuery,
                                              "DepartmentID", "Name", selectedDepartment);
        }
        public ActionResult Delete(Department department)
        {
            DepartmentClient departmentClient = new DepartmentClient();
            bool             result           = departmentClient.Delete(department.id);

            if (result)
            {
                ViewBag.msg = "Department Delete Successfully!";
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.msg = "Error To Delete Department!";
                return(RedirectToAction("Delete", department.id));
            }
        }
        public ActionResult Edit(Department department)
        {
            DepartmentClient departmentClient = new DepartmentClient();
            bool             result           = departmentClient.Edit(department);

            if (result)
            {
                ViewBag.msg = "Department Edit Successfully!";
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.msg = "Error To Save Department!";
                return(RedirectToAction("Edit", department));
            }
        }
 public DepartmentClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(DepartmentClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
 public DepartmentClient(EndpointConfiguration endpointConfiguration) :
     base(DepartmentClient.GetBindingForEndpoint(endpointConfiguration), DepartmentClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
 public DepartmentClient() :
     base(DepartmentClient.GetDefaultBinding(), DepartmentClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IDepartment.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(DepartmentClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IDepartment));
 }
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(DepartmentClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IDepartment));
 }