コード例 #1
0
ファイル: HomeController.cs プロジェクト: frandi/ANTAMFeed
        public ActionResult Edit(int? id)
        {
            ViewData[Constants.SUCCESS_MESSAGE] = TempData[Constants.SUCCESS_MESSAGE];

            IGoldPriceService svc = new GoldPriceService();

            GoldPrice model = null;

            // try getting from database
            if (id != null)
                model = svc.Get(id.Value);

            // try getting from previously fetched data from ANTAM
            if (model == null)
                model = TempData[Constants.PRICE_FROM_ANTAM] as GoldPrice;

            // just create new object
            if (model == null)
            {
                model = new GoldPrice();
                model.PriceDate = DateTime.Today;
            }

            return View(model);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: frandi/ANTAMFeed
        public ActionResult Details(int id)
        {
            IGoldPriceService svc = new GoldPriceService();
            GoldPrice model = svc.Get(id);

            if (model == null)
                return RedirectToAction("Index");

            return View(model);
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: frandi/ANTAMFeed
        public ActionResult Edit(GoldPrice item)
        {
            IGoldPriceService svc = new GoldPriceService();

            if (svc.Save(item))
            {
                TempData[Constants.SUCCESS_MESSAGE] = "Success";
                return RedirectToAction("Edit", new { id = item.GoldPriceID });
            }

            TempData[Constants.ERROR_MESSAGE] = "Failed!!!";
            return View(item);
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: frandi/ANTAMFeed
 public ActionResult Index()
 {
     IGoldPriceService svc = new GoldPriceService();
     IEnumerable<GoldPrice> models = svc.Find(DateTime.Today.AddDays(-DateTime.Today.Day), DateTime.Today);
     return View(models);
 }