Exemplo n.º 1
0
        public ActionResult UpdateDelete(RegularPriceTierViewModel RPTViewModel, string command)
        {
            string PageAction = "";
            bool   result     = false;

            user = (UserSession)Session["User"];

            if (command == "Save")
            {
                RegularPriceTierManager RPTManager = new RegularPriceTierManager();
                result     = RPTManager.UpdateRegularPriceTier(RPTViewModel);
                PageAction = "UPDATE";
            }
            else if (command == "Delete")
            {
                RegularPriceTierManager RPTManager = new RegularPriceTierManager();
                result     = RPTManager.DeleteRegularPriceTier(RPTViewModel);
                PageAction = "DELETE";
            }
            if (result)
            {
                TempData["SuccessMessage"] = PageAction + " successful";
                new AuditLogManager().Audit(user.Username, DateTime.Now, "Regular Price Tier", PageAction, RPTViewModel.Id, RPTViewModel.Price_Tier);
            }
            else
            {
                TempData["ErrorMessage"] = PageAction + " failed";
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        // GET: RegularPriceTier
        public ActionResult Index()
        {
            // Validate log in and user access
            UserAccessSession UASession = (UserAccessSession)Session["UserAccess"];

            // TIP -> Price Tier
            // Refer to UserAccessSession
            if (UASession == null || !UASession.TIP)
            {
                return(RedirectToAction("Login", "Account"));
            }

            user = (UserSession)Session["User"];
            Session["CurrentPage"] = new CurrentPageSession("TIP_REG", "HOME", "LOG");

            // Get all data stored in DB table
            RegularPriceTierManager   RPTManager   = new RegularPriceTierManager();
            RegularPriceTierViewModel RPTViewModel = new RegularPriceTierViewModel();

            RPTViewModel.RegPTList = RPTManager.GetRPT();
            if (RPTViewModel.RegPTList == null || RPTViewModel.RegPTList.Count() == 0)
            {
                RPTViewModel.RegPTList = new List <RegularPriceTierViewModel>();
            }
            // return View with ViewModel
            return(View(RPTViewModel));
        }
Exemplo n.º 3
0
 public List <RegularPriceTierViewModel> GetRPT()
 {
     using (CFMMCDEntities db = new CFMMCDEntities())
     {
         List <RegularPriceTierViewModel> RPTList = new List <RegularPriceTierViewModel>();
         foreach (Regular_Price_Tier rpt in db.Regular_Price_Tier)
         {
             RegularPriceTierViewModel RPTViewModel = new RegularPriceTierViewModel();
             RPTViewModel.Id         = (rpt.Id).ToString();
             RPTViewModel.Price_Tier = rpt.Price_Tier;
             // Add to List
             RPTList.Add(RPTViewModel);
         }
         return(RPTList);
     }
 }
Exemplo n.º 4
0
 public bool UpdateRegularPriceTier(RegularPriceTierViewModel RPTViewModel)
 {
     using (CFMMCDEntities db = new CFMMCDEntities())
     {
         Regular_Price_Tier rptRow = new Regular_Price_Tier();
         rptRow.Id         = int.Parse(RPTViewModel.Id);
         rptRow.Price_Tier = RPTViewModel.Price_Tier;
         try
         {
             if (db.Regular_Price_Tier.Where(o => o.Id.ToString().Equals(RPTViewModel.Id)).Any())
             {
                 var rowToRemove = db.Regular_Price_Tier.Single(o => o.Id.ToString().Equals(RPTViewModel.Id));
                 db.Regular_Price_Tier.Remove(rowToRemove);
                 db.Regular_Price_Tier.Add(rptRow);
             }
             else
             {
                 db.Regular_Price_Tier.Add(rptRow);
             }
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.Source);
             System.Diagnostics.Debug.WriteLine(e.Message);
             System.Diagnostics.Debug.WriteLine(e.StackTrace);
             System.Diagnostics.Debug.WriteLine(e.InnerException);
             Exception f = e.InnerException;
             while (f != null)
             {
                 System.Diagnostics.Debug.WriteLine("INNER:");
                 System.Diagnostics.Debug.WriteLine(f.Message);
                 System.Diagnostics.Debug.WriteLine(f.Source);
                 f = f.InnerException;
             }
             System.Diagnostics.Debug.WriteLine(e.Data);
             return(false);
         }
     }
 }