public EntityAdd GetEntityAdd() { var result = new EntityAdd(); result.EntityExternalRef = EntityView.EntityExternalRef; result.EntityId = EntityView.EntityId; result.LogoURL = EntityView.LogoURL; result.Name = EntityView.Name; result.SMTPEmailDisplayName = EntityView.SMTPEmailDisplayName; result.SMTPEmailFromAddress = EntityView.SMTPEmailFromAddress; result.SMTPHost = EntityView.SMTPHost; result.SMTPPassword = EntityView.SMTPPassword; result.SMTPUserName = EntityView.SMTPUserName; return(result); }
// Add Transaction Code public async Task <EntityView> Add(EntityAdd add) { try { using (var db = new data.InvoiceContext()) { var result = await Add(db, add); await db.SaveChangesAsync(); return((EntityView)result); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task AddEntityAsync(EntityAdd model) { if (string.IsNullOrWhiteSpace(model.EntityTypeName)) { throw new ArgumentException("Entity type is not specified"); } var entityTypeName = model.EntityTypeName.Trim().ToLowerInvariant(); var json = model.Data; var jsonValueKind = json.ValueKind; if (jsonValueKind != JsonValueKind.Object && jsonValueKind != JsonValueKind.Array) { throw new ArgumentException("Invalid json"); } await ProcessEntitiesInternalAsync(entityTypeName, json); await dbContext.SaveChangesAsync(); }
public async Task <EntityView> EntityAdd(EntityAdd add) { try { string json = ""; var client = new HttpClient(); using (var ms = new MemoryStream()) { var serializer = new DataContractJsonSerializer(typeof(EntityAdd)); serializer.WriteObject(ms, add); ms.Position = 0; StreamReader sr = new StreamReader(ms); json = sr.ReadToEnd(); } var stream = await client.PostAsync("http://localhost:44443/api/entity", new StringContent(json, Encoding.UTF8, "application/json")); using (var ms = new MemoryStream()) { var serializer = new DataContractJsonSerializer(typeof(EntityView), new DataContractJsonSerializerSettings() { DateTimeFormat = new DateTimeFormat("yyyy-MM-dd'T'HH:mm:ss") }); await stream.Content.CopyToAsync(ms); ms.Position = 0; var view = serializer.ReadObject(ms) as EntityView; return(view); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Entity> Add(data.InvoiceContext db, EntityAdd add) { try { var newEntity = new data.Entity(); newEntity.Address = add.Address; newEntity.EntityExternalRef = add.EntityExternalRef; newEntity.LogoURL = add.LogoURL; newEntity.Name = add.Name; newEntity.SMTPEmailDisplayName = add.SMTPEmailDisplayName; newEntity.SMTPEmailFromAddress = add.SMTPEmailFromAddress; newEntity.SMTPHost = add.SMTPHost; newEntity.SMTPPassword = add.SMTPPassword; newEntity.SMTPUserName = add.SMTPUserName; db.Entitys.Add(newEntity); return(newEntity); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public void registerEntityAdd(EntityAdd e) { EntityAddListeners.Add(e); }
public async Task <IActionResult> CreateEntity(EntityAdd model) { await entityService.AddEntityAsync(model); return(Ok()); }