private string GetOperationReturnType(IOperationModel o) { if (o.ReturnType == null) { return(o.IsAsync() ? "async Task" : "void"); } return(o.IsAsync() ? $"async Task<{GetTypeName(o.ReturnType.TypeReference)}>" : GetTypeName(o.ReturnType.TypeReference)); }
public string GetImplementation(IMetaDataManager metaDataManager, SoftwareFactory.Engine.IApplication application, IClass domainModel, IOperationModel operationModel) { var idParam = operationModel.Parameters.First(p => string.Equals(p.Name, "id", StringComparison.OrdinalIgnoreCase)); var dtoParam = operationModel.Parameters.First(p => !string.Equals(p.Name, "id", StringComparison.OrdinalIgnoreCase)); return($@"var existing{domainModel.Name} ={ (operationModel.IsAsync() ? " await" : "") } {domainModel.Name.ToPrivateMember()}Repository.FindById{ (operationModel.IsAsync() ? "Async" : "") }({idParam.Name}); {EmitPropertyAssignments(metaDataManager, application, domainModel, "existing"+ domainModel.Name, dtoParam)}"); }
public override string AfterCallToAppLayer(IServiceModel service, IOperationModel operation) { if (operation.Stereotypes.Any(x => x.Name == "ReadOnly")) { return(""); } return(operation.IsAsync() ? $@" await _dbContext.SaveChangesAsync();" : $@" _dbContext.SaveChanges();"); }
public string GetImplementation(IMetaDataManager metaDataManager, SoftwareFactory.Engine.IApplication application, IClass domainModel, IOperationModel operationModel) { return($@"var existing{domainModel.Name} ={ (operationModel.IsAsync() ? " await" : "") } {domainModel.Name.ToPrivateMember()}Repository.FindById{ (operationModel.IsAsync() ? "Async" : "") }(id); {domainModel.Name.ToPrivateMember()}Repository.Remove(existing{domainModel.Name});"); }
public string GetImplementation(IMetaDataManager metaDataManager, SoftwareFactory.Engine.IApplication application, IClass domainModel, IOperationModel operationModel) { return($@"var elements ={ (operationModel.IsAsync() ? "await" : "") } {domainModel.Name.ToPrivateMember()}Repository.FindAll{ (operationModel.IsAsync() ? "Async" : "") }(); return elements.MapTo{domainModel.Name.ToPascalCase()}DTOs();"); }