CodeLiturgy.Dashboard/BlueWest.Api/Context/Templates/UpdateEntityTemplate.csx

14 lines
583 B
Plaintext
Raw Normal View History

2022-08-27 06:19:30 +03:00
using Microsoft.EntityFrameworkCore;
namespace {Namespace}
{
public static partial class {entityTypeName}Extensions {
public static (bool, {readTypeFullName}) Update{entityTypeName}(
this {contextFullName} dbContext, {updateTypeFullName} {toUpdateVarName}) {
var {newEntityVarName} = new {entityTypeFullName}({toUpdateVarName});
2022-08-27 06:19:30 +03:00
dbContext.{propertyName}.Add({newEntityVarName});
var success = dbContext.SaveChanges() >= 0;
return (success, new {readTypeFullName}({newEntityVarName}));
}
}
}