Пример #1
0
        // GET: Portal/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            new_pyta entity = (new_pyta)context.Retrieve("new_pyta", new Guid(id), new ColumnSet(true));

            List<SelectListItem> wydawcyList = new List<SelectListItem>();

            IQueryable<new_wydawca> wydawcy = context.new_wydawcaSet.Select(row => row);

            foreach (var item in wydawcy)
            {
                if (item.new_wydawcaId == entity.new_Wydawca.Id)
                {
                    wydawcyList.Add(new SelectListItem { Text = item.new_name, Value = item.new_wydawcaId.ToString(), Selected = true});
                }
                else
                {
                    wydawcyList.Add(new SelectListItem { Text = item.new_name, Value = item.new_wydawcaId.ToString() });
                }

            }

            List<SelectListItem> rankingList = new List<SelectListItem>();

            OptionMetadataCollection omc = getOptionSetValues("new_pyta", "new_ranking");

            foreach (var item in omc)
            {
                string val = getOptionSetText("new_pyta", "new_ranking", (int)item.Value);
                int key = (int)item.Value;

                if (key == entity.new_Ranking)
                {
                    rankingList.Add(new SelectListItem { Text = val, Value = key.ToString(), Selected = true});
                }
                else
                {
                    rankingList.Add(new SelectListItem { Text = val, Value = key.ToString() });
                }

            }

            PortalViewModel pvm = new PortalViewModel();

            pvm.Autor = entity.new_Autor;
            pvm.Nazwa = entity.new_name;

            if (entity == null)
            {
                return HttpNotFound();
            }

            ViewBag.Ranking = rankingList;
            ViewBag.Wydawca = wydawcyList;

            return View(pvm);
        }
Пример #2
0
        // GET: Portal/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            new_pyta entity = (new_pyta)context.Retrieve("new_pyta", new Guid(id), new ColumnSet(true));

            PortalViewModel pvm = new PortalViewModel();
            pvm.Autor = entity.new_Autor;
            pvm.Nazwa = entity.new_name;
            pvm.ID = entity.Id;
            pvm.Ranking = getOptionSetText("new_pyta", "new_ranking", (int)entity.new_Ranking);
            pvm.Wydawca = entity.new_Wydawca.Name;

            return View(pvm);
        }
Пример #3
0
        // GET: Portal/Details/5
        public ActionResult Details(Guid id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            new_pyta plyta = (new_pyta)context.Retrieve("new_pyta", id, new ColumnSet(true));

            PortalViewModel pm = new PortalViewModel();

            pm.Autor = plyta.new_Autor;
            pm.ID = plyta.Id;
            pm.Nazwa = plyta.new_name;
            pm.Ranking = getOptionSetText("new_pyta", "new_ranking", plyta.new_Ranking.Value);
            pm.Wydawca = plyta.new_Wydawca.Name;

            if (pm == null)
            {
                return HttpNotFound();
            }
            return View(pm);
        }