public virtual T Save(T item) { var savedItem = Db.Save(item); var id = GetId(item); Cache.Trigger(TriggerFor.Id <T>(id)); return(savedItem); }
public ActionResult AuthResponse(string token) { var sessionToken = AuthSubUtil.exchangeForSessionToken(token, null); var settings = _siteSettingsService.GetSettings(); settings.AnalyticsToken = sessionToken; Db.Save(settings); Cache.Trigger(TriggerFor.Id <SiteSettings>(settings.Id)); return(Redirect(Url.AdminHome())); }
public virtual void SoftUndelete(T item) { var id = GetId(item); Db.Execute("update [{0}] set IsDeleted=0 where Id=@Id".Fmt( Db.GetTableName <T>() ), new { id }); Cache.Trigger(TriggerFor.Id <T>(id)); }
//public virtual T GetByIdOrDefault(object id) //{ // return Cache.GetOrCache(GetIdCacheKey(id), context => // { // //var item = Db.GetByIdOrDefault<T>(id); // //if (item != null) // // context.InvalidateOn(TriggerFrom.Id<T>(id)); // //return item; // }); //} public virtual void SoftDelete(T item) { var id = GetId(item); //Db.Execute("update [{0}] set IsDeleted=1 where Id=@Id".Fmt( // Db.GetTableName<T>() //), new //{ // id //}); Cache.Trigger(TriggerFor.Id <T>(id)); }
public ActionResult AnalyticsConfig(Config model) { var settings = _siteSettingsService.GetSettings(); var profiles = GetProfiles(settings); var profile = profiles.SingleOrDefault(x => x.Id == model.ProfileId); if (profile == null) { throw new Exception("Unable to find the specified analytics profile: " + model.ProfileId); } settings.AnalyticsProfileId = profile.Id; Db.Save(settings); Cache.Trigger(TriggerFor.Id <SiteSettings>(settings.Id)); return(Redirect(Url.AdminHome())); }
public ActionResult ResetPassword(ResetPassword model) { if (User.Identity.IsAuthenticated) { NotifyInfo("You are already logged in. Log out and try again."); return(Redirect(Url.Home().Index())); } if (ModelState.IsValid) { model.Data = Db.SingleOrDefault <PasswordRetrieval>(new { model.Token }); if (model.Data == null) { NotifyWarning("Sorry! We couldn't verify that this user requested a password reset. Please try resetting again."); return(Redirect(Url.Account().ForgotPassword())); } var user = Db.Query <User>("delete from [{0}] where Id=@resetId;update [{1}] set Password=@Password, ModifiedOn=GetUtcDate() where Id=@UserId;select * from [{1}] where Id=@UserId" .Fmt( Db.GetTableName <PasswordRetrieval>(), Db.GetTableName <User>() ), new { ResetId = model.Data.Id, Password = model.Password.ToSHAHash(), model.Data.UserId }).SingleOrDefault(); Cache.Trigger(TriggerFor.Id <User>(user.Id)); _authenticationService.SetLoginCookie(user, true); Metrics.Increment(Metric.Users_ResetPassword); //show confirmation return(View("ResetPasswordConfirmation")); } return(View(model)); }