Ejemplo n.º 1
0
        // POST: Missions/Edit/5
        // Чтобы защититься от атак чрезмерной передачи данных, включите определенные свойства, для которых следует установить привязку. Дополнительные
        // сведения см. в статье http://go.microsoft.com/fwlink/?LinkId=317598.

        /// <summary>
        ///     The delete.
        /// </summary>
        /// <param name="id">
        ///     The id.
        /// </param>
        /// <returns>
        ///     The <see cref="Task" />.
        /// </returns>
        public async Task <ActionResult> Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var mission = await _missionService.GetMission(id);

            if (mission == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PersonQualities = await _personQualityService.GetPersonQualities();

            return(View(mission));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> CreateMissionFromDraft(string id)
        {
            var missionDraft = await _missionDraftService.GetMissionDraft(id);

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

            var result = await _missionService.AddNewMission(missionDraft);

            if (result.Status == OperationResultStatus.Success)
            {
                await _missionDraftService.DeleteMissionDraft(id);

                return(RedirectToAction("Index"));
            }
            ViewBag.PersonQualities = await _personQualityService.GetPersonQualities();

            return(View("Details", missionDraft));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Indexes the specified page.
        /// </summary>
        /// <param name="page">
        ///     The page.
        /// </param>
        /// <returns>
        ///     Task{ActionResult}.
        /// </returns>
        public async Task <ActionResult> Index([FromUri] int?page)
        {
            var       pageNumber    = page ?? 0;
            const int ItemsOnPage   = 15;
            var       selectOptions = new QueryOptions <PersonQuality>
            {
                /*Filter = p => p.Author == "Defor",*/
                Skip   = pageNumber * ItemsOnPage,
                Top    = ItemsOnPage + 1,
                Select = draft =>
                         new
                {
                    draft.Id,
                    draft.Name,
                    draft.Description
                }
            };
            var types = await _personQualityService.GetPersonQualities(selectOptions);

            IEnumerable <PersonQuality> model;

            if (types.Count <= ItemsOnPage)
            {
                ViewBag.ShowNext = false;
                model            = types;
            }
            else
            {
                ViewBag.ShowNext = true;
                model            = types.Take(ItemsOnPage);
            }

            ViewBag.ShowPrevious = pageNumber != 0;
            ViewBag.CurrentPage  = pageNumber;
            return(View(model));
        }