Beispiel #1
0
        public ContentResult TrgovanjeHnbSave(long trgovanjeGlavaHnbId, string trgovanjeGlavaHnbJson, string trgovanjeStavkaHnbCollectionJson)
        {
            string returnJson;

            DataAccessAdapterBase adapter = Helper.GetDataAccessAdapterFactory(User.Identity.Name);

            try
            {
                adapter.StartTransaction(System.Data.IsolationLevel.Serializable, "TrgovanjeHnbSave");
                TrgovanjeHnbViewModel viewModel = new TrgovanjeHnbViewModel(adapter, trgovanjeGlavaHnbId);
                viewModel.UpdateModelFromJson(trgovanjeGlavaHnbJson, trgovanjeStavkaHnbCollectionJson);
                viewModel.Save(adapter);

                adapter.Commit();

                string url = this.Url.Action("TrgovanjeHnbEdit", new { trgovanjeGlavaHnbId = viewModel.TrgovanjeGlavaHnb.TrgovanjeGlavaHnbId });
                returnJson = string.Format("{{ \"Url\": \"{0}\" }}", url);
            }
            catch (UserException ex)
            {
                returnJson = string.Format("{{ \"Error\": \"{0}\" }}", ex.Message);
                adapter.Rollback();
            }
            catch (Exception)
            {
                adapter.Rollback();
                throw;
            }
            finally
            {
                adapter.Dispose();
            }

            return new ContentResult() { Content = returnJson, ContentType = "application/json" };
        }
Beispiel #2
0
 public ActionResult TrgovanjeHnbEdit(long? trgovanjeGlavaHnbId)
 {
     DataAccessAdapterBase adapter = Helper.GetDataAccessAdapterFactory();
     using (adapter)
     {
         TrgovanjeHnbViewModel viewModel = new TrgovanjeHnbViewModel(adapter, trgovanjeGlavaHnbId);
         viewModel.LoadViewSpecificData(adapter);
         return View(viewModel);
     }
 }