public RazorTemplate SaveTemplate(string viewName, string viewData) { if(string.IsNullOrEmpty(viewData)) { throw new ArgumentNullException("viewData"); } var template = _documentSession.Load<RazorTemplate>(FormatId(viewName)); if(template == null) { template = new RazorTemplate { Id = FormatId(viewName), ViewName = viewName, ViewData = viewData }; template.SetCreatedFields(_userIdentity.UserName); return _documentSession.StoreSaveEvict(template); } else { template.ViewData = viewData; template.SetUpdatedFields(_userIdentity.UserName); return _documentSession.SaveEvict(template); } }
public RazorTemplate SaveTemplate(string viewName, string viewData) { if (string.IsNullOrEmpty(viewName)) { throw new ArgumentNullException("viewName"); } if(string.IsNullOrEmpty(viewData)) { throw new ArgumentNullException("viewData"); } using (var db = _sqlConnectionInfo.GetDB()) { var item = db.FirstOrDefault<RazorTemplate>("FROM RazorTemplate WHERE ViewName=@0", viewName); if (item == null) { item = new RazorTemplate { Id = Guid.NewGuid().ToString(), ViewName = viewName, ViewData = viewData }; item.SetCreatedFields(_userIdentity.UserName); db.Insert("RazorTemplate", "ID", false, item); } else { item.ViewData = viewData; item.SetUpdatedFields(_userIdentity.UserName); db.Update("RazorTemplate", "ID", item, item.Id); } return item; } }
public RazorTemplate GetTemplate(string viewName, string defaultViewData) { var item = _documentSession.Load<RazorTemplate>(FormatId(viewName)); if(item == null) { item = new RazorTemplate { ViewName = viewName, ViewData = defaultViewData }; }; return item; }
public RazorTemplate GetTemplate(string viewName, string defaultViewData) { if(string.IsNullOrEmpty(viewName)) { throw new ArgumentNullException("viewName"); } using(var db = _sqlConnectionInfo.GetDB()) { var item = db.FirstOrDefault<RazorTemplate>("FROM RazorTemplate WHERE ViewName=@0", viewName); if(item == null) { item = new RazorTemplate { ViewName = viewName, ViewData = defaultViewData }; } return item; } }