AssocManyToMany.Controllers.MatchesController.EmployeeAndJobDuties C# (CSharp) Метод

EmployeeAndJobDuties() публичный Метод

public EmployeeAndJobDuties ( int id ) : System.Web.Mvc.ActionResult
id int
Результат System.Web.Mvc.ActionResult
        public ActionResult EmployeeAndJobDuties(int? id)
        {
            // Attempt to fetch the matching object
            var o = m.EmployeeGetByIdWithDetail(id.GetValueOrDefault());

            if (o == null)
            {
                return HttpNotFound();
            }
            else
            {
                // Create a form, based on the fetched matching object
                var form = AutoMapper.Mapper.Map<EmployeeEditJobDutiesForm>(o);

                // For the multi select list, configure the "selected" items
                // Notice the use of the Select() method, 
                // which allows us to select/return/use only some properties from the source
                var selectedValues = o.JobDuties.Select(jd => jd.Id);

                // For clarity, use the named parameter feature of C#
                form.JobDutyList = new MultiSelectList
                    (items: m.JobDutyGetAll(),
                    dataValueField: "Id",
                    dataTextField: "FullName",
                    selectedValues: selectedValues);

                return View(form);
            }
        }

Same methods

MatchesController::EmployeeAndJobDuties ( int id, EmployeeEditJobDuties newItem ) : System.Web.Mvc.ActionResult