public IHttpActionResult GetById(int id) { var model = _universityInfo.GetById(id); if (model != null) { UniversityInfoViewModel VM = new UniversityInfoViewModel { 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, RectorId = model.ApplicationUserrId, RectorMessage = model.RectorMessage, }; return(Ok(VM)); } return(Ok("Item Not Found !")); }
public IHttpActionResult Update(UniversityInfoViewModel model) { UniversityInfo data = new UniversityInfo { 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, ApplicationUserrId = model.RectorId, RectorMessage = model.RectorMessage, }; _universityInfo.Update(data); return(Ok(data)); }
public ActionResult EditUniversityNews(int id) { if (id > 0) { var university = _universityInfo.GetById(id); if (university != null) { var vm = new UniversityInfoViewModel { 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, RectorId = university.ApplicationUserrId, RectorMessage = university.RectorMessage }; 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.Rector = new SelectList(result, "Id", "RectorNameSurname"); return(View("AddUniversityInfo", vm)); } } return(View("AddUniversityInfo")); }