public ActionResult UpdateLocalReport([DataSourceRequest] DataSourceRequest request, UpdateLocalReportViewModel model) { using (var repository = GetRepository()) { var result = ValidateLocalTaxonomyReportFields(model); if (result.ValidationMessages.Count > 0) { return(new JsonHttpStatusResult(new { Message = result.ValidationMessages }, HttpStatusCode.InternalServerError)); } if (model.Id != model.OldId) { if (!IsLocalReportUniqueId(model.TaxonomyId, model.Id)) { model.Id = model.OldId; return(new JsonHttpStatusResult(new { Message = UserMessages.TAXSONOMY_IS_NOT_UNIQ_ID }, HttpStatusCode.InternalServerError)); } } var entity = new LocalReportModel() { Currency = model.Currency, Decimals = model.Decimals, DecimalDecimals = model.DecimalDecimals, Description = model.Description, EntityIdentifier = model.EntityIdentifire == null?"":model.EntityIdentifire.Id, EntitySchema = model.EntitySchema, EntryUri = model.EntryUri, FileName = model.FileName, Id = model.Id, IntegerDecimals = model.IntegerDecimals, MonetaryDecimals = model.MonetaryDecimals, PeriodType = model.PeriodType == null?null: model.PeriodType.PeriodType, PureDecimals = model.PureDecimals, SharesDecimals = model.SharesDecimals, TaxonomyId = model.TaxonomyId, TnProcessorId = model.TnProcessorId, TnRevisionId = model.TnRevisionId, SourceId = model.SourceId == null ? null : model.SourceId.Id, UpdateDate = DateTime.Now }; try { repository.LocalReportRepository.Update(model.OldSourceId, model.OldId, entity); repository.Commit(); } catch (Exception e) { GetLogger().LogException(e, string.Format("UpdateLocalReports({0})", entity.TaxonomyId)); return(new JsonHttpStatusResult(new { Message = UserMessages.UNKNOWN_ERROR }, HttpStatusCode.InternalServerError)); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public void Remove(LocalReportModel entity) { LogLine(string.Format("remove {0} - {1} from database.", entity.Id, entity.Description)); int rowsAffected = 0; rowsAffected = Connection.Execute(@"DELETE FROM XMS_LOCAL_REPORTS WHERE TAXONOMY_ID = :TaxonomyId AND SOURCE_ID = :SourceId AND ID = :Id", new { Id = entity.Id, SourceId = entity.SourceId, TaxonomyId = entity.TaxonomyId }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Remove LocalReport failed rowsAffected :" + rowsAffected); } }
public void Add(LocalReportModel entity) { LogLine(string.Format("adding {0} - {1} to database.", entity.Id, entity.Description)); int rowsAffected = Connection.Execute(@"INSERT INTO XMS_LOCAL_REPORTS (TAXONOMY_ID, SOURCE_ID, ID, ENTRY_URI, FILE_NAME, DESCRIPTION, ENTITY_IDENTIFIER, PERIOD_TYPE, CURRENCY, DECIMALS, ENTITY_SCHEMA, DECIMAL_DECIMALS, INTEGER_DECIMALS, MONETARY_DECIMALS, PURE_DECIMALS, SHARES_DECIMALS, TN_PROCESSOR_ID, TN_REVISION_ID, UPDATE_USER, UPDATE_USER_DSC, UPDATE_DATE) VALUES (:TaxonomyId, :SourceId, :Id, :EntryUri, :FileName, :Description, :EntityIdentifire, :PeriodType, :Currency, :Decimals, :EntitySchema, :DecimalDecimals, :IntegerDecimals, :MonetaryDecimals, :PureDecimals, :SharesDecimals, :TnProcessorId, :TnRevisionId, :UpdateDate, :UpdateUser, :UpdateUserDsc)", new { Description = entity.Description, PeriodType = OracleHelpers.PeriodTypeToString(entity.PeriodType), TaxonomyId = entity.TaxonomyId, Id = entity.Id, SourceId = entity.SourceId, 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, TnRevisionId = entity.TnRevisionId, UpdateDate = entity.UpdateDate, UpdateUser = entity.UpdateUser, UpdateUserDsc = entity.UpdateUserDsc, }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Add LocalReport failed rowsAffected :" + rowsAffected); } }
public void Update(string oldSourceId, string oldId, LocalReportModel entity) { LogLine(string.Format("update {0} - {1} in database.", entity.Id, entity.Description)); int rowsAffected = Connection.Execute(@"UPDATE XMS_LOCAL_REPORTS SET SOURCE_ID = :SourceId, ID = :Id, ENTRY_URI = :EntryUri, FILE_NAME = :FileName, DESCRIPTION = :Description, ENTITY_IDENTIFIER = :EntityIdentifire, PERIOD_TYPE = :PeriodType, 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 = :TnRevisionId , UPDATE_USER = :UpdateUser , UPDATE_USER_DSC = :UpdateUserDsc , UPDATE_DATE = :UpdateDate WHERE TAXONOMY_ID = :TaxonomyId AND ID = :OldId AND SOURCE_ID = :OldSourceId", new { Description = entity.Description, PeriodType = OracleHelpers.PeriodTypeToString(entity.PeriodType), TaxonomyId = entity.TaxonomyId, Id = entity.Id, SourceId = entity.SourceId, 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, TnRevisionId = entity.TnRevisionId, UpdateDate = entity.UpdateDate, UpdateUser = entity.UpdateUser, UpdateUserDsc = entity.UpdateUserDsc, OldSourceId = oldSourceId, OldId = oldId }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Update LocalReport failed rowsAffected :" + rowsAffected); } }