Пример #1
0
        public ActionResult SaveConfig(ConfigEntity config)
        {
            bool isSaved = false;

            if (config.AktivnaGodina >= 2005 && config.AktivnaGodina <= 2025)
            {
                DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter(User.Identity.Name);
                using (adapter)
                {
                    adapter.StartTransaction(System.Data.IsolationLevel.Serializable, "SaveConfig");

                    ConfigEntity config4Save;
                    if (config.ConfigId == 0)
                    {
                        config4Save         = config;
                        config4Save.FirmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                    }
                    else
                    {
                        config4Save = ConfigEntity.FetchConfig(adapter, null, config.ConfigId);
                        config4Save.UpdateDataFromOtherObject(config, null, null);
                    }

                    isSaved = adapter.SaveEntity(config4Save);

                    adapter.Commit();
                }
            }

            dynamic response = new { IsSaved = isSaved };

            return(CreateJsonResponse(response));
        }