コード例 #1
0
        // GET: CheckLists/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CheckListEntity checkListEntity = db.CheckLists.Find(id);

            if (checkListEntity == null)
            {
                return(HttpNotFound());
            }
            return(View(checkListEntity));
        }
コード例 #2
0
        // GET: CheckLists/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CheckListEntity checkListEntity = db.CheckLists.Find(id);

            if (checkListEntity == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Components = db.Components.ToList();
            return(View(checkListEntity));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            //todo recursively delete items?
            CheckListEntity checkListEntity = db.CheckLists.Find(id);

            checkListEntity.CheckListItems =
                new List <CheckListItem>(db.CheckListItems.Where(c => c.CheckListId == checkListEntity.CheckListEntityId));
            if (!checkListEntity.CheckListItems.IsNullOrEmpty())
            {
                foreach (var item in checkListEntity.CheckListItems)
                {
                    db.CheckListItems.Remove(checkListEntity.CheckListItems.GetEnumerator().Current);
                }
            }
            db.CheckLists.Remove(checkListEntity);
            db.SaveChanges();
            return(RedirectToAction("CheckLists"));
        }
コード例 #4
0
        public ActionResult Execute([Bind(Include = "CheckListEntityId,CheckListName")] CheckListEntity checkListEntity)
        {
            //TODO exception
            if (ModelState.IsValid)
            {
//                checkListEntity.CheckListItems =
//                    db.CheckListItems.Where(c => c.CheckListId == checkListEntity.CheckListEntityId);
                if (checkListEntity.CheckListItems == null)
                {
                    return(HttpNotFound());
                }
                checkListEntity.CheckListItems.GetEnumerator().Current.LastExecutionDateTime = DateTime.Now;
                checkListEntity.CheckListItems.GetEnumerator().Current.LastExecutorCheckListUser = Repository.CurrentUser;
                db.Entry(checkListEntity.CheckListItems.GetEnumerator().Current).State = EntityState.Modified;
                db.SaveChanges();
//                return View(checkListEntity);
            }

            return(View(checkListEntity));
        }
コード例 #5
0
        public ActionResult Execute(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CheckListEntity checkListEntity = db.CheckLists.Find(id);

            if (checkListEntity == null)
            {
                return(HttpNotFound());
            }
            SelectList testResult = new SelectList(db.TestResults, "TestResultId", "TestResultValue");

            ViewBag.TestResults            = testResult;
            checkListEntity.CheckListItems =
                new List <CheckListItem>(db.CheckListItems.Where(c => c.CheckListId == checkListEntity.CheckListEntityId));
            if (checkListEntity.CheckListItems == null)
            {
                return(HttpNotFound());
            }
            return(View(checkListEntity));
        }
コード例 #6
0
        public ActionResult Edit([Bind(Include = "CheckListEntityId,CheckListName,LastEditionDateTime")] CheckListEntity checkListEntity, int[] selectedComponents)
        {
            if (ModelState.IsValid)
            {
                checkListEntity.LastEditionDateTime     = DateTime.Now;
                checkListEntity.LastEditorCheckListUser = Repository.CurrentUser;
                if (selectedComponents != null)
                {
                    List <Component> components = new List <Component>();
                    //получаем выбранные курсы
                    foreach (var c in db.Components.Where(co => selectedComponents.Contains(co.ComponentId)))
                    {
                        components.Add(c);
                    }

                    checkListEntity.Components = components;
                }
                db.Entry(checkListEntity).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("CheckLists"));
            }
            return(View(checkListEntity));
        }
コード例 #7
0
        // GET: CheckLists/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CheckListEntity checkListEntity = db.CheckLists.Find(id);

            if (checkListEntity == null)
            {
                return(HttpNotFound());
            }
            checkListEntity.CheckListItems =
                new List <CheckListItem>(db.CheckListItems.Where(c => c.CheckListId == checkListEntity.CheckListEntityId));
            if (checkListEntity.CheckListItems == null)
            {
                return(HttpNotFound());
            }
//            checkListEntity.CheckListItems.GetEnumerator().Current.CheckListTestResult =
//                db.TestResults.Find(checkListEntity.CheckListItems.GetEnumerator().Current.CheckListTestResult
//                    .TestResultId);

            return(View(checkListEntity));
        }