예제 #1
0
        public IHttpActionResult GetById(int id)
        {
            var model = _facultyInfo.GetById(id);

            if (model != null)
            {
                FacultyInfoViewModel VM = new FacultyInfoViewModel
                {
                    Id          = model.Id,
                    Name        = model.Name,
                    History     = model.History,
                    Mission     = model.Mission,
                    Vission     = model.Vission,
                    Address     = model.Address,
                    Phone       = model.Phone,
                    FaxNo       = model.FaxNo,
                    Email       = model.Email,
                    DeanId      = model.ApplicationUserrId,
                    DeanMessage = model.DeanMessage
                };

                return(Ok(VM));
            }
            return(Ok("Item Not Found !"));
        }
        public ActionResult EditInfo(int id)
        {
            if (id > 0)
            {
                var university = _facultyInfo.GetById(id);
                if (university != null)
                {
                    var vm = new FacultyInfoViewModel
                    {
                        Id          = university.Id,
                        Name        = university.Name,
                        History     = university.History,
                        Mission     = university.Mission,
                        Vission     = university.Vission,
                        Address     = university.Address,
                        Phone       = university.Phone,
                        FaxNo       = university.FaxNo,
                        Email       = university.Email,
                        DeanId      = university.ApplicationUserrId,
                        DeanMessage = university.DeanMessage
                    };

                    var result = (from user in db.Users
                                  select new UserViewModel()
                    {
                        Id = user.Id,
                        FirstName = user.FirstName,
                        LastName = user.LastName,
                        RectorNameSurname = user.FirstName + " " + user.LastName
                    }).ToList();
                    ViewBag.Dean = new SelectList(result, "Id", "RectorNameSurname");


                    var uni = _universityBusiness.GetAll().ToList();
                    ViewBag.University = new SelectList(uni, "Id", "Name");

                    return(View("AddFacultyInfo", vm));
                }
            }

            return(View("AddFacultyInfo"));
        }