public async Task <TemplateEditViewModel> GetEditViewTemplate(int templateId) { NotificationTemplateEntityModel template = await Db.NotificationTemplates.FindAsync(templateId); TemplateEditViewModel model = new TemplateEditViewModel(template, User.TimeZoneInfoId); return(model); }
public async Task UpdateEditViewTemplate(TemplateEditViewModel template) { NotificationTemplateEntityModel update = await Db.NotificationTemplates.FindAsync(template.TemplateID); await Db.Entry(update).Reference(r => r.CreatedBy).LoadAsync(); update.EmailBody = template.EmailBody; update.Subject = template.Subject; update.TextMessage = template.TextMessage; update.UpdatedBy = User; update.UpdatedDt = DateTimeOffset.Now; await Db.SaveChangesAsync().ConfigureAwait(continueOnCapturedContext: false); }
public TemplateEditViewModel(NotificationTemplateEntityModel template, string timezoneInfoId) { TemplateID = template.NotificationTemplateId; Name = template.Name; Fields = template.Options; EmailBody = template.EmailBody; Subject = template.Subject; TextMessage = template.TextMessage; var updateBy = template.UpdatedBy ?? template.CreatedBy; UpdatedBy = $"{updateBy.LastName}, {updateBy.FirstName}"; var updateDt = template.UpdatedDt ?? template.CreatedDt; UpdatedDt = updateDt.ConvertToUserTime(timezoneInfoId); }