public void Remove(LocalEntityModel entity) { LogLine(string.Format("remove {0} - {1} from database.", entity.Id, entity.Description)); int rowsAffected = Connection.Execute(@"DELETE FROM XMS_LOCAL_ENTITIES WHERE ID = :Id ", new { Id = entity.Id }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Remove Taxonomy failed rowsAffected :" + rowsAffected); } }
public void Add(LocalEntityModel entity) { LogLine(string.Format("adding {0} - {1} to database.", entity.Id, entity.Description)); int rowsAffected = Connection.Execute(@"INSERT INTO XMS_LOCAL_ENTITIES ( ID,DESCRIPTION) VALUES (:Id, :Description) ", new { Description = entity.Description, Id = entity.Id }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Add LocalEntity failed rowsAffected :" + rowsAffected); } }
public JsonResult UpdateLocalEntities([DataSourceRequest] DataSourceRequest request, UpdateLocalEntityViewModel 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.Id != model.OldId) { if (!IsLocalEntityUniqueId(model.Id)) { model.Id = model.OldId; return(new JsonHttpStatusResult(new { Message = UserMessages.TAXSONOMY_IS_NOT_UNIQ_ID }, HttpStatusCode.InternalServerError)); } } var entity = new LocalEntityModel() { Description = model.Description, Id = model.Id }; try { repository.LocalEntityRepository.Update(model.OldId, entity); } catch (Exception e) { GetLogger().LogException(e, string.Format("UpdateTaxonomies({0})", model.Id)); return(new JsonHttpStatusResult(new { Message = UserMessages.UNKNOWN_ERROR }, HttpStatusCode.InternalServerError)); } repository.Commit(); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public void Update(string oldId, LocalEntityModel entity) { LogLine(string.Format("update {0} - {1} in database.", entity.Id, entity.Description)); int rowsAffected = Connection.Execute(@"UPDATE XMS_LOCAL_ENTITIES SET ID = :Id, DESCRIPTION = :Description WHERE ID = :OldId ", new { Description = entity.Description, Id = entity.Id, OldId = oldId }); if (rowsAffected == 0) { throw new NoRowsAffectedException("Update LocalEntity failed rowsAffected :" + rowsAffected); } }
public IActionResult EntityManagerLocalNewSave(LocalEntityModel model) { string sql = "SELECT entitysettings.createentityfrommodel(@p_synapsenamespaceid, @p_synapsenamespacename, @p_entityname, @p_entitydescription, @p_username, @p_localnamespaceid, @p_localnamespacename)"; string localtablename = SynapseHelpers.GetLocalNamespaceNameFromID(model.LocalNamespaceId) + "_" + model.EntityName; var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("p_synapsenamespaceid", namespaceId), new KeyValuePair <string, string>("p_synapsenamespacename", SynapseHelpers.GetNamespaceNameFromID(namespaceId)), new KeyValuePair <string, string>("p_entityname", localtablename), new KeyValuePair <string, string>("p_entitydescription", model.EntityDescription == null ? "" : model.EntityDescription), new KeyValuePair <string, string>("p_username", HttpContext.Session.GetString(SynapseSession.FullName)), new KeyValuePair <string, string>("p_localnamespaceid", localNamespaceIDSelected), new KeyValuePair <string, string>("p_localnamespacename", SynapseHelpers.GetLocalNamespaceNameFromID(localNamespaceIDSelected)), }; DataSet ds = new DataSet(); ds = DataServices.DataSetFromSQL(sql, paramList); DataTable dt = ds.Tables[0]; string newGuid = dt.Rows[0][0].ToString(); return(Json(newGuid)); }