Exemple #1
0
        public ActionResult AddTaxonomyReports([DataSourceRequest] DataSourceRequest request, TaxonomyReportViewModel model)
        {
            using (var repository = GetRepository())
            {
                if (model != null && ModelState.IsValid)
                {
                    if (!IsTaxonomyReportUniqueId(model.TaxonomyId, model.Id))
                    {
                        return(new JsonHttpStatusResult(new { Message = UserMessages.TAXSONOMY_IS_NOT_UNIQ_ID }, HttpStatusCode.InternalServerError));
                    }

                    var result = ValidateTaxonomyReportFields(model);

                    if (result.ValidationMessages.Count > 0)
                    {
                        return(new JsonHttpStatusResult(new { Message = result.ValidationMessages }, HttpStatusCode.InternalServerError));
                    }

                    var entity = new TaxonomyReportModel()
                    {
                        Currency         = model.Currency,
                        Decimals         = model.Decimals,
                        DecimalDecimals  = model.DecimalDecimals,
                        Description      = model.Description,
                        EntityIdentifier = model.EntityIdentifire,
                        EntitySchema     = model.EntitySchema,
                        EntryUri         = model.EntryUri,
                        FileName         = model.FileName,
                        Id = model.Id,
                        IntegerDecimals  = model.IntegerDecimals,
                        MonetaryDecimals = model.MonetaryDecimals,
                        PeriodType       = model.PeriodType.PeriodType.Value,
                        PureDecimals     = model.PureDecimals,
                        SharesDecimals   = model.SharesDecimals,
                        TaxonomyId       = model.TaxonomyId,
                        TnProcessorId    = model.TnProcessorId,
                        TnRevisionId     = model.TnRevisionId,
                    };

                    try
                    {
                        repository.TaxonomyReportRepository.Add(entity);
                        repository.Commit();
                    }
                    catch (Exception e)
                    {
                        GetLogger().LogException(e, string.Format("AddTaxonomyReports({0})", model.TaxonomyId));
                        return(new JsonHttpStatusResult(new { Message = UserMessages.UNKNOWN_ERROR }, HttpStatusCode.InternalServerError));
                    }
                }
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public void Update(TaxonomyReportModel entity)
        {
            LogLine(string.Format("update {0} - {1} in database.", entity.Id, entity.Description));

            int rowsAffected = Connection.Execute(@"UPDATE  XMS_TAXONOMY_REPORTS  
                            SET DESCRIPTION =: Description,
                            PERIOD_TYPE = :PeriodType,  
                            ENTRY_URI = :EntryUri, 
                            FILE_NAME = :FileName,  
                            ENTITY_IDENTIFIER = :EntityIdentifire,  
                            CURRENCY = :Currency, 
                            DECIMALS = :Decimals, 
                            ENTITY_SCHEMA = :EntitySchema, 
                            DECIMAL_DECIMALS = :DecimalDecimals, 
                            INTEGER_DECIMALS = :IntegerDecimals, 
                            MONETARY_DECIMALS = :MonetaryDecimals, 
                            PURE_DECIMALS = :PureDecimals, 
                            SHARES_DECIMALS = :SharesDecimals, 
                            TN_PROCESSOR_ID = :TnProcessorId, 
                            TN_REVISION_ID = :TnRevisonId
                            WHERE TAXONOMY_ID = :TaxonomyId  and ID = :Id",
                                                  new
            {
                Description      = entity.Description,
                PeriodType       = OracleHelpers.PeriodTypeToString(entity.PeriodType),
                TaxonomyId       = entity.TaxonomyId,
                Id               = entity.Id,
                EntryUri         = entity.EntryUri,
                FileName         = entity.FileName,
                EntityIdentifire = entity.EntityIdentifier,
                Currency         = entity.Currency,
                Decimals         = entity.Decimals,
                EntitySchema     = entity.EntitySchema,
                DecimalDecimals  = entity.DecimalDecimals,
                IntegerDecimals  = entity.IntegerDecimals,
                MonetaryDecimals = entity.MonetaryDecimals,
                PureDecimals     = entity.PureDecimals,
                SharesDecimals   = entity.SharesDecimals,
                TnProcessorId    = entity.TnProcessorId,
                TnRevisonId      = entity.TnRevisionId,
            }
                                                  );

            if (rowsAffected == 0)
            {
                throw new NoRowsAffectedException("Update TaxonomyReport failed rowsAffected :" + rowsAffected);
            }
        }
        public void Remove(TaxonomyReportModel entity)
        {
            LogLine(string.Format("remove {0} - {1} from database.", entity.Id, entity.Description));
            int rowsAffected = 0;

            rowsAffected = Connection.Execute(@"DELETE FROM XMS_TAXONOMY_REPORTS  
                                                        WHERE TAXONOMY_ID = :TaxonomyId AND ID = :Id",
                                              new
            {
                Id         = entity.Id,
                TaxonomyId = entity.TaxonomyId
            });
            if (rowsAffected == 0)
            {
                throw new NoRowsAffectedException("Remove TaxonomyReport failed rowsAffected :" + rowsAffected);
            }
        }
        public void Add(TaxonomyReportModel entity)
        {
            LogLine(string.Format("adding {0} - {1} to database.", entity.Id, entity.Description));

            int rowsAffected = Connection.Execute(@"INSERT INTO XMS_TAXONOMY_REPORTS (DESCRIPTION,
                                                                              PERIOD_TYPE,
                                                                              ENTRY_URI, 
                                                                              FILE_NAME, 
                                                                              ENTITY_IDENTIFIER,
                                                                              CURRENCY, 
                                                                              DECIMALS, 
                                                                              ENTITY_SCHEMA, 
                                                                              DECIMAL_DECIMALS, 
                                                                              INTEGER_DECIMALS, 
                                                                              MONETARY_DECIMALS,
                                                                              PURE_DECIMALS,
                                                                              SHARES_DECIMALS,
                                                                              TN_PROCESSOR_ID,
                                                                              TN_REVISION_ID,
                                                                              TAXONOMY_ID,
                                                                              ID)
                                                                       VALUES (:Description,
                                                                                :PeriodType,
                                                                                :EntryUri,
                                                                                :FileName,
                                                                                :EntityIdentifire,
                                                                                :Currency, 
                                                                                :Decimals,
                                                                                :EntitySchema,
                                                                                :DecimalDecimals,
                                                                                :IntegerDecimals,
                                                                                :MonetaryDecimals,
                                                                                :PureDecimals,
                                                                                :SharesDecimals,
                                                                                :TnProcessorId,
                                                                                :TnRevisonId,
                                                                                :TaxonomyId,
                                                                                :Id) ",
                                                  new
            {
                Description      = entity.Description,
                PeriodType       = OracleHelpers.PeriodTypeToString(entity.PeriodType),
                TaxonomyId       = entity.TaxonomyId,
                Id               = entity.Id,
                EntryUri         = entity.EntryUri,
                FileName         = entity.FileName,
                EntityIdentifire = entity.EntityIdentifier,
                Currency         = entity.Currency,
                Decimals         = entity.Decimals,
                EntitySchema     = entity.EntitySchema,
                DecimalDecimals  = entity.DecimalDecimals,
                IntegerDecimals  = entity.IntegerDecimals,
                MonetaryDecimals = entity.MonetaryDecimals,
                PureDecimals     = entity.PureDecimals,
                SharesDecimals   = entity.SharesDecimals,
                TnProcessorId    = entity.TnProcessorId,
                TnRevisonId      = entity.TnRevisionId,
            });

            if (rowsAffected == 0)
            {
                throw new NoRowsAffectedException("Add TaxonomyReport failed   rowsAffected :" + rowsAffected);
            }
        }