Exemplo n.º 1
0
        public ActionResult CreatePrice(PackageVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    tbl_PackagePrice price = new tbl_PackagePrice()
                    {
                        PackageID   = viewModel.PackageID,
                        Source_EVID = viewModel.Source_EVID,
                        BeginDate   = viewModel.BeginDate,
                        EndDate     = viewModel.EndDate,
                        Price       = viewModel.Price,
                        Point       = viewModel.Point,
                        InsertDate  = DateTime.Now,
                        InsertUser  = UserProfile.UserId
                    };

                    CRUDOperation    operations = new CRUDOperation();
                    tbl_PackagePrice itemDB     = operations.AddPackagePrice(price);
                    if (itemDB != null)
                    {
                        TempData["success"] = "Ok";
                        TempData["message"] = "Məlumatlar uğurla əlavə olundu";
                        return(RedirectToAction("PriceIndex", new { packageID = itemDB.PackageID }));
                    }
                    else
                    {
                        TempData["success"] = "notOk";
                        TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi";
                        return(RedirectToAction("PriceIndex", new { packageID = itemDB.PackageID }));
                    }
                }
                throw new ApplicationException("Invalid model");
            }
            catch (ApplicationException ex)
            {
                viewModel = populatePriceDropDownList(viewModel);
                return(View(viewModel));
            }
        }