public ActionResult UpdateTaxonomies([DataSourceRequest] DataSourceRequest request, UpdateTaxonomyViewModel model) { if (model != null && ModelState.IsValid) { using (var repository = GetRepository()) { var result = ValidateTaxonomyFields(model); if (result.ValidationMessages.Count > 0) { return(new JsonHttpStatusResult(new { Message = result.ValidationMessages }, HttpStatusCode.InternalServerError)); } if (model.TaxonomyId != model.OldTaxonomyId) { if (!IsTaxonomyUniqueId(model.TaxonomyId)) { model.TaxonomyId = model.OldTaxonomyId; return(new JsonHttpStatusResult(new { Message = UserMessages.TAXSONOMY_IS_NOT_UNIQ_ID }, HttpStatusCode.InternalServerError)); } } var entity = new TaxonomyModel() { Currency = model.Currency, DecimalDecimals = model.DecimalDecimals, Decimals = model.Decimals, Description = model.Description, EntityIdentifier = model.EntityIdentifier, EntitySchema = model.EntitySchema, IntegerDecimals = model.IntegerDecimals, MonetaryDecimals = model.MonetaryDecimals, PureDecimals = model.PureDecimals, SharesDecimals = model.SharesDecimals, TaxonomyCreationDate = model.TaxonomyCreationDate, TaxonomyDate = model.TaxonomyDate, TaxonomyId = model.TaxonomyId, TnProcessorId = model.TnProcessorId, TnRevisionId = model.TnRevisionId, }; try { repository.TaxonomyRepository.Update(model.OldTaxonomyId, entity); repository.Commit(); } catch (Exception e) { GetLogger().LogException(e, string.Format("UpdateTaxonomies({0})", model.TaxonomyId)); return(new JsonHttpStatusResult(new { Message = UserMessages.UNKNOWN_ERROR }, HttpStatusCode.InternalServerError)); } } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public void Update(string oldTaxonomyId, TaxonomyModel entity) { int rowsAffected = 0; LogLine(string.Format("update {0} - {1} in database.", entity.TaxonomyId, entity.Description)); rowsAffected = Connection.Execute(@"UPDATE XMS_TAXONOMIES SET DESCRIPTION =: Description, TAXONOMY_ID = :TaxonomyId, TAXONOMY_DATE = :TaxonomyDate, ENTITY_IDENTIFIER = :EntityIdentifier, CURRENCY = :Currency, DECIMALS = :Decimals, ENTITY_SCHEMA = :EntitySchema, TAXONOMY_CREATION_DATE = :TaxonomyCreationDate, TN_PROCESSOR_ID = :TnProcessorId, DECIMAL_DECIMALS = :DecimalDecimals, INTEGER_DECIMALS = :IntegerDecimals, MONETARY_DECIMALS = :MonetaryDecimals, PURE_DECIMALS = :PureDecimals, SHARES_DECIMALS = :SharesDecimals, TN_REVISION_ID = :TnRevisionId WHERE TAXONOMY_ID = :OldTaxonomyId", new { Description = entity.Description, TaxonomyId = entity.TaxonomyId, TaxonomyDate = entity.TaxonomyDate, EntityIdentifier = entity.EntityIdentifier, Currency = entity.Currency, Decimals = entity.Decimals, EntitySchema = entity.EntitySchema, TaxonomyCreationDate = entity.TaxonomyCreationDate, TnProcessorId = entity.TnProcessorId, DecimalDecimals = entity.DecimalDecimals, IntegerDecimals = entity.IntegerDecimals, MonetaryDecimals = entity.MonetaryDecimals, PureDecimals = entity.PureDecimals, SharesDecimals = entity.SharesDecimals, TnRevisionId = entity.TnRevisionId, OldTaxonomyId = oldTaxonomyId }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Update Taxonomy failed rowsAffected :" + rowsAffected); } }
public void Remove(TaxonomyModel entity) { LogLine(string.Format("remove {0} - {1} from database.", entity.TaxonomyId, entity.Description)); int rowsAffected = 0; rowsAffected = Connection.Execute(@"DELETE FROM XMS_TAXONOMIES WHERE TAXONOMY_ID = :TaxonomyId ", new { TaxonomyId = entity.TaxonomyId }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Remove Taxonomy failed rowsAffected :" + rowsAffected); } }
public async Task <List <TaxonomyModel> > SaveTags(List <TagModel> tags, ArticleModel article) { var taxonomiesList = new List <TaxonomyModel>(); foreach (var tag in tags) { var taxonomy = new TaxonomyModel { Tag = tag, Article = article }; taxonomiesList.Add(taxonomy); await _context.Taxonomies.AddAsync(taxonomy); } await _context.SaveChangesAsync(); return(taxonomiesList); }
public async Task <List <TaxonomyModel> > SaveCategories(List <CategoryModel> categories, ArticleModel article) { var taxonomiesList = new List <TaxonomyModel>(); foreach (var category in categories) { var taxonomy = new TaxonomyModel { Category = category, Article = article }; taxonomiesList.Add(taxonomy); await _context.Taxonomies.AddAsync(taxonomy); } await _context.SaveChangesAsync(); return(taxonomiesList); }
private TaxonomyViewModel CreateTaxonomyViewModel(TaxonomyModel model) { return(new TaxonomyViewModel() { Description = model.Description, TaxonomyId = model.TaxonomyId, Currency = model.Currency, DecimalDecimals = model.DecimalDecimals, Decimals = model.Decimals, EntityIdentifier = model.EntityIdentifier, EntitySchema = model.EntitySchema, IntegerDecimals = model.IntegerDecimals, MonetaryDecimals = model.MonetaryDecimals, PureDecimals = model.PureDecimals, SharesDecimals = model.SharesDecimals, TaxonomyCreationDate = model.TaxonomyCreationDate, TaxonomyDate = model.TaxonomyDate, TnProcessorId = model.TnProcessorId, TnRevisionId = model.TnRevisionId }); }
public void Add(TaxonomyModel entity) { LogLine(string.Format("adding {0} - {1} to database.", entity.TaxonomyId, entity.Description)); int rowsAffected = 0; rowsAffected = Connection.Execute(@"INSERT INTO XMS_TAXONOMIES ( TAXONOMY_ID, DESCRIPTION, TAXONOMY_DATE, ENTITY_IDENTIFIER, CURRENCY, DECIMALS, ENTITY_SCHEMA, TAXONOMY_CREATION_DATE, TN_PROCESSOR_ID, DECIMAL_DECIMALS, INTEGER_DECIMALS, MONETARY_DECIMALS, PURE_DECIMALS, SHARES_DECIMALS, TN_REVISION_ID) VALUES (:TaxonomyId, :Description, :TaxonomyDate, :EntityIdentifier, :Currency, :Decimals, :EntitySchema, :TaxonomyCreationDate, :TnProcessorId, :DecimalDecimals, :IntegerDecimals, :MonetaryDecimals, :PureDecimals, :SharesDecimals, :TnRevisionId ) ", new { Description = entity.Description, TaxonomyId = entity.TaxonomyId, TaxonomyDate = entity.TaxonomyDate, EntityIdentifier = entity.EntityIdentifier, Currency = entity.Currency, Decimals = entity.Decimals, EntitySchema = entity.EntitySchema, TaxonomyCreationDate = entity.TaxonomyCreationDate, TnProcessorId = entity.TnProcessorId, DecimalDecimals = entity.DecimalDecimals, IntegerDecimals = entity.IntegerDecimals, MonetaryDecimals = entity.MonetaryDecimals, PureDecimals = entity.PureDecimals, SharesDecimals = entity.SharesDecimals, TnRevisionId = entity.TnRevisionId, }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Add Taxonomy failed rowsAffected :" + rowsAffected); } }