コード例 #1
0
        /// <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));
        }
コード例 #2
0
        public HouseDetailsViewModel(House house)
        {
            this.ID         = house.ID;
            this.FamilyName = house.FamilyName;
            this.Address    = house.Address;
            this.HasChimney = house.HasChimney;

            Kids = KidsManager.GetKidsInHouse(house.ID);
        }
コード例 #3
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;
        }
コード例 #4
0
        public ActionResult Create(KidUpdateRequestViewModel requestModel)
        {
            var kid = new Kid();

            requestModel.UpdateKidModel(kid);

            bool success = KidsManager.Save(kid);

            var viewModel = new KidUpdateResponseViewModel(kid);

            viewModel.UpdateSuccess = success;

            return(RedirectToAction("Details", new { id = kid.ID }));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        /// <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));
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        /// <summary>
        /// This page should simply load a paginated list of kids
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var kids = KidsManager.GetAll();

            return(View(kids));
        }
コード例 #9
0
        /// <summary>
        /// This page should show a paginated list of all children who are either naughty or nice, as determined by the nice parameter
        /// </summary>
        /// <param name="nice">Whether to load the nice list or the naughty list</param>
        /// <returns></returns>
        public ActionResult List(bool nice)
        {
            var kids = KidsManager.GetList(nice);

            return(View("~/Views/Kids/Index.cshtml", kids));
        }