CodeLiturgy.Dashboard/CodeLiturgy.Domain/Templates/AddToTemplate.csx

14 lines
682 B
Plaintext
Raw Normal View History

2022-09-01 08:54:42 +03:00
/// <summary>
2022-09-05 05:58:37 +03:00
/// Adds a new {entityTypeName} and returns a projection of type {returnTypeFullName}.
2022-09-01 08:54:42 +03:00
/// </summary>
/// <param name="dbContext">The database context.</param>
2022-09-05 05:58:37 +03:00
/// <param name="{toCreateVarName}">Projection data of {entityTypeName}</param>
2022-09-01 08:54:42 +03:00
/// <returns>The added data.</returns>
public static (bool, {returnTypeFullName}) Add{entityTypeName}(this {contextFullName} dbContext, {createTypeFullName} {toCreateVarName})
{
var {newEntityVarName} = new {entityTypeFullName}({toCreateVarName});
dbContext.{propertyName}.Add({newEntityVarName});
var success = dbContext.SaveChanges() >= 0;
return (success, new {returnTypeFullName}({newEntityVarName}));
2022-08-28 20:00:09 +03:00
}