Пример #1
0
        /// <summary>
        /// Action Method to display a form to update the hostel fees
        /// </summary>
        /// <param name="userInput"> the serach query as input by the user</param>
        /// <returns>Partial View</returns>
        public ActionResult ChangeFees(SearchViewModel userInput)
        {
            TransactionHelper helper = new TransactionHelper();

            HostelChargesViewModel model = helper.ConstructViewModelForHostelFeeChange(userInput);

            TempData["canRentChange"]    = helper.CanChangeRent(userInput.hostelType, userInput.roomType);
            TempData["canFixChange"]     = helper.CanChangeFix(userInput.hostelType, userInput.roomType);
            TempData["canDepositChange"] = helper.CanChangeDep(userInput.hostelType, userInput.roomType);

            TempData["originalValues"] = model;
            TempData["rentId"]         = helper.GetRentFeeId(userInput.hostelType, userInput.roomType);;
            TempData["fixId"]          = helper.GetFixFeeId(userInput.hostelType, userInput.roomType);;
            TempData["depId"]          = helper.GetDepFeeId(userInput.hostelType, userInput.roomType);;
            return(PartialView("_FeeChange", model));
        }
Пример #2
0
        /// <summary>
        /// Action Method to save the changes to the fees made by the user
        /// </summary>
        /// <param name="userInput"> the changes made to the fees by the user</param>
        /// <returns>PartialView or Success Message</returns>
        public ActionResult UpdateFees(HostelChargesViewModel userInput)
        {
            // if model is not valid, do not process furthur
            if (!ModelState.IsValid)
            {
                return(PartialView("_FeeChange", userInput));
            }

            // get previously saved value
            HostelChargesViewModel originalValues = TempData.Peek("originalValues") as HostelChargesViewModel;

            // get the previously saved IDs
            int rentId = (int)TempData.Peek("rentId");
            int fixId  = (int)TempData.Peek("fixId");
            int depId  = (int)TempData.Peek("depId");

            TransactionHelper helper = new TransactionHelper();

            return(Content(helper.ChangeHostelFees(userInput, originalValues, rentId, fixId, depId)));
        }