Exemplo n.º 1
0
        // GET: Providers/Edit
        public ActionResult Edit(Guid?id)
        {
            var viewModel = new ProviderUniversitiesModel();

            LMSProvider lMSProvider = db.LMSProviders.Find(id);

            if (lMSProvider == null)
            {
                return(HttpNotFound());
            }
            else
            {
                viewModel.Provider = lMSProvider;
                List <CourseUniversityLM> lst = db.CourseUniversityLMS.Where(a => a.ProviderId == lMSProvider.ProviderId).ToList();
                if (lst.Count > 0)
                {
                    foreach (var item in lst)
                    {
                        University university = db.Universities.Find(item.UniversityId);
                        viewModel.Universities.Add(university);
                    }
                }
            }
            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Edit(ProviderUniversitiesModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (viewModel.Provider.ProviderId != new Guid())
                {
                    db.Entry(viewModel.Provider).State = EntityState.Modified;
                }
                //else
                //{
                //    viewModel.Provider.ProviderCreateDate = DateTime.Now;
                //    viewModel.Provider.ProviderId = Guid.NewGuid();
                //    db.LMSProviders.Add(viewModel.Provider);
                //}
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }