public async Task SetDefaultOtrSaveMode(FSharpOption <OtrSaveMode> value) { using (var context = this.CreateContext()) { var user = await GetUser(context); if (value == FSharpOption <OtrSaveMode> .None) { user.Expire = null; user.OtrMode = Model.OtrMode.NotSet; user.SaveMode = Model.SaveMode.NotSet; } else { var saveMode = value.Value; if (saveMode.Expire != FSharpOption <long> .None) { user.Expire = FSharpHelper.FromFSharpS(saveMode.Expire); } if (saveMode.OtrMode != FSharpOption <OtrMode> .None) { user.OtrMode = FromFSharp(saveMode.OtrMode.Value); } if (saveMode.SaveMode != FSharpOption <SaveMode> .None) { user.SaveMode = FromFSharp(saveMode.SaveMode.Value); } } await context.MySaveChanges(); } }
public async Task SetItem(JabberId jid, OtrSaveMode saveMode) { using (var context = this.CreateContext()) { var user = await GetUser(context); var savedItem = await (from item in context.UserItemPreferences where item.ArchivingUserId == UserId && item.Jid == jid.FullId select item).FirstOrDefaultAsync(); if (savedItem == null) { savedItem = new Model.DbUserItemPreference(); savedItem.ArchivingUserId = UserId; savedItem.Jid = jid.FullId; context.UserItemPreferences.Add(savedItem); } if (saveMode.Expire != FSharpOption <long> .None) { savedItem.Expire = FSharpHelper.FromFSharpS(saveMode.Expire); } if (saveMode.OtrMode != FSharpOption <OtrMode> .None) { savedItem.OtrMode = FromFSharp(saveMode.OtrMode.Value); } if (saveMode.SaveMode != FSharpOption <SaveMode> .None) { savedItem.SaveMode = FromFSharp(saveMode.SaveMode.Value); } await context.MySaveChanges(); } }
public async Task SetArchiving(FSharpOption <bool> value) { using (var context = this.CreateContext()) { var user = await GetUser(context); if (value != FSharpOption <bool> .None) { user.AutomaticArchiving = FSharpHelper.FromFSharpS(value); } await context.MySaveChanges(); } }