예제 #1
0
파일: Employee.cs 프로젝트: seif/Northwind
        // See: EmployeeController.Details for Script.Literal() explanation
        public void DisplayForm(Employee employee)
        {
            jQueryObject employeeForm = jQueryTemplating.RenderTemplate(jQuery.Select("#employee-form-tmpl").GetHtml(), employee);

            jQuery.Select("#main").Append(employeeForm);
            jQuery.Select("#employee-form").Cast<Dialogs>()
                                           .Dialog(Script.Literal(@"{minWidth:500,close: function(event, ui){$(this).dialog('destroy').remove();}}"));
        }
예제 #2
0
파일: Employee.cs 프로젝트: seif/Northwind
        public void ShowValidationResults(Employee employee)
        {
            foreach (ValidationResult validationResult in employee.ValidationResultsJson)
            {
                if (validationResult.PropertyName == "FirstName")
                {
                    jQuery.Select("#FirstName").Append("<div class=\"error-message\">" + validationResult.Message + "</div>");
                }

                if (validationResult.PropertyName == "LastName")
                {
                    jQuery.Select("#LastName").Append("<div class=\"error-message\">" + validationResult.Message + "</div>");
                }

                if (validationResult.PropertyName == "PhoneExtension")
                {
                    jQuery.Select("#PhoneExtension").Append("<div class=\"error-message\">" + validationResult.Message + "</div>");
                }
            }

            jQuery.Select("#employee-save").Attribute("disabled", string.Empty);
        }
예제 #3
0
        private void Create(jQueryEvent eventHandler)
        {
            eventHandler.PreventDefault();

            if (eventHandler.CurrentTarget.ID == "create-employee")
            {
                Employee employee = new Employee();
                this.employeeService.DisplayForm(employee);
                return;
            }

            jQuery.Select(".error-message").Remove();
            jQuery.Select("#employee-save").Attribute("disabled", "true");

            jQuery.Post(
                        "EmployeeRia/Edit",
                        jQuery.Select("#employee-form-create").Serialize(),
                        delegate(object response)
                        {
                            Employee employee = (Employee)response;

                            if (employee.Valid)
                            {
                                jQuery.Select("#main").Empty();
                                jQuery.Select("#employee-form").Remove();

                                // This just makes a round-trip and reinitializes
                                // the table. In most cases you would just add the
                                // returned employee to the UI
                                this.Initialize();
                                return;
                            }

                            this.employeeService.ShowValidationResults(employee);
            });
        }
예제 #4
0
 private void GetCurrentEmployeeById(string id)
 {
     foreach (Employee employee in this.employeeViewModel.Employees)
     {
         if (employee.Id.ToString() == id)
         {
             employee.TerritoriesString = this.territoryService.TerritoriestoCSV(employee.Territories);
             this.SelectedEmployee = employee;
             break;
         }
     }
 }