/// <summary>
        /// This page should allow the user to edit a kid's records.
        /// </summary>
        /// <returns></returns>
        public ActionResult Update(int id)
        {
            var kid       = KidsManager.GetByID(id);
            var viewModel = new KidUpdateResponseViewModel(kid);

            return(View("~/Views/Kids/AddOrUpdate.cshtml", viewModel));
        }
Exemplo n.º 2
0
        public DeedDetailsViewModel(Deed deed)
        {
            this.KidID       = deed.KidID;
            this.Description = deed.Description;
            this.TimeOfDeed  = deed.TimeOfDeed;
            this.Weight      = deed.Weight;
            this.IsNice      = deed.IsNice;

            var kid = KidsManager.GetByID(deed.KidID);

            this.KidName = kid.Name;
        }
        public ActionResult Update(int id, KidUpdateRequestViewModel requestModel)
        {
            var kid = KidsManager.GetByID(id);

            requestModel.UpdateKidModel(kid);

            bool success = KidsManager.Save(kid);

            var viewModel = new KidUpdateResponseViewModel(kid);

            viewModel.UpdateSuccess = success;

            return(View("~/Views/Kids/AddOrUpdate.cshtml", viewModel));
        }
        /// <summary>
        /// This page should load details about the specific kid, given the kid Id, and return a view with the relevant data.
        /// Such data would include all the kid's actions, the presents being prepared for them, and their status on naughty/nice list.
        /// </summary>
        /// <param name="kidId">The ID of the kid to load data about</param>
        /// <returns></returns>
        public ActionResult Details(int id)
        {
            var kid = KidsManager.GetByID(id);

            if (kid == null)
            {
                return(RedirectToAction("Index"));
            }

            var isNice   = KidsManager.IsKidNice(id);
            var deeds    = KidsManager.GetDeeds(id);
            var presents = KidsManager.GetPresents(id);

            var viewModel = new KidDetailsViewModel(kid, isNice, deeds, presents);

            return(View(viewModel));
        }
        public PresentDetailsViewModel(Present present)
        {
            var kid = KidsManager.GetByID(present.KidID);

            this.KidID   = present.KidID;
            this.KidName = kid.Name;

            var item = DataManager <Item> .GetByID(present.ItemID);

            this.ItemID   = present.ItemID;
            this.ItemName = item.Name;

            var elf = ElvesManager.GetByID(present.ElfID);

            this.ElfID   = present.ElfID;
            this.ElfName = elf.Name;

            this.IsDone = present.IsDone;
        }