Ejemplo n.º 1
0
        public ActionResult CommitLessonPrice(LessonPriceViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;

            if (!ModelState.IsValid)
            {
                ViewBag.ModelState = ModelState;
                return(View("EditLessonPrice"));
            }

            LessonPriceType item = models.GetTable <LessonPriceType>()
                                   .Where(p => p.PriceID == viewModel.PriceID).FirstOrDefault();

            if (item == null)
            {
                item = new LessonPriceType
                {
                    PriceID = models.GetTable <LessonPriceType>().Select(p => p.PriceID).Max() + 1,
                    Status  = (int)Naming.DocumentLevelDefinition.正常
                };
                models.GetTable <LessonPriceType>().InsertOnSubmit(item);
            }

            item.CoachPayoff           = viewModel.CoachPayoff;
            item.CoachPayoffCreditCard = viewModel.CoachPayoffCreditCard;
            item.Description           = viewModel.Description;
            item.UsageType             = viewModel.UsageType;
            item.ListPrice             = viewModel.ListPrice;

            models.SubmitChanges();
            ViewBag.Message = "資料已儲存!!";

            return(ConfigureAll());
        }
Ejemplo n.º 2
0
        public ActionResult EditLessonPrice(int?priceID)
        {
            LessonPriceViewModel viewModel = new LessonPriceViewModel {
            };
            LessonPriceType item           = models.GetTable <LessonPriceType>().Where(p => p.PriceID == priceID).FirstOrDefault();

            if (item != null)
            {
                viewModel.PriceID               = item.PriceID;
                viewModel.Description           = item.Description;
                viewModel.ListPrice             = item.ListPrice;
                viewModel.Status                = item.Status;
                viewModel.UsageType             = item.UsageType;
                viewModel.CoachPayoff           = item.CoachPayoff;
                viewModel.CoachPayoffCreditCard = item.CoachPayoffCreditCard;
            }
            ViewBag.ViewModel = viewModel;

            return(View());
        }