Example #1
0
        public ActionResult Create(ExchangeRate item)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", item));
            }

            var qry = from x in ExchangeRate.Queryable
                      where x.Date == item.Date.Date &&
                      x.Base == item.Base &&
                      x.Target == item.Target
                      select x;

            if (qry.Count() > 0)
            {
                ModelState.AddModelError("Date", Resources.ExchangeRateAlreadyExists);
                return(PartialView("_Create", item));
            }

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_CreateSuccesful", item));
        }
Example #2
0
        public ActionResult Create(ExchangeRate item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Create", item);

            var qry = from x in ExchangeRate.Queryable
                  where x.Date == item.Date.Date &&
                        x.Base == item.Base &&
                        x.Target == item.Target
                  select x;

            if (qry.Count () > 0) {
                ModelState.AddModelError ("Date", Resources.ExchangeRateAlreadyExists);
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }