Created
February 4, 2018 18:15
-
-
Save foyzulkarim/e9fff4a589b9ef1dfaab49ee31bfe343 to your computer and use it in GitHub Desktop.
Create default instance of the provided type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseReportService | |
{ | |
protected T CreateDefault<T>(Type t, string shopId) where T : BaseReport | |
{ | |
var report = Activator.CreateInstance(t) as BaseReport; | |
report.Id = Guid.NewGuid().ToString(); | |
report.Created = DateTime.Now; | |
report.Modified = DateTime.Now; | |
report.CreatedBy = "System"; | |
report.ModifiedBy = "System"; | |
report.CreatedFrom = "System"; | |
report.IsActive = true; | |
report.Value = report.Created.Date.ToString("dd/MM/yyyy"); | |
report.Date = report.Created.Date; | |
report.RowsCount = 0; | |
report.ShopId = shopId; | |
return report as T; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment