How to save the settings of an authentication id in ASP.NET MVC












0















I have made an tv-guide where you can see the programs for 5 channels. If you login you can also make an "personal" tvguide. where you can decide which of the 5 channels you are interested in seeing the tableau of, by clicking on their checkboxes. How can I make the application remember the user input. So let's say I log in and open the menu for Channel one (SVT1), and two (SVT2). Then I want these two channels also to be open next time I log in with that user id, how do I do that?



Screenshot of my personal tv-guide page



My controller



public class FavoritChannelsController : Controller
{
TvProgramDBEntities db = new TvProgramDBEntities();

[Authorize(Roles = "User")]
public ActionResult channel_index()
{
List<Full> model = new List<Full>();
var list = db.Full.Where(d => d.Date == "2018-11-12").ToList();

foreach (var item in list)
{
if (item.Id <1000)
{
var initedF = new Full
{
Channel = Regex.Replace(item.Channel, @"s", ""),
Program = item.Program,
Time = item.Time,
Date = Regex.Replace(item.Date, @"s", "")
};
model.Add(initedF);
}

}
return View(model);
}
}


My view



@model IEnumerable<Uppgift4.Models.Full>

@{
ViewBag.Title = "channel_Index";
var list = Model.ToList();
var list1 = list.Where(_ => _.Channel == "SVT1").Select(_ => _.Time +
_.Program).ToList();
var list2 = list.Where(_ => _.Channel == "SVT2").Select(_ => _.Time +
_.Program).ToList();
var list3 = list.Where(_ => _.Channel == "TV3").Select(_ => _.Time +
_.Program).ToList();
var list4 = list.Where(_ => _.Channel == "TV4").Select(_ => _.Time +
_.Program).ToList();
var list5 = list.Where(_ => _.Channel == "Kanal5").Select(_ => _.Time +
_.Program).ToList();
}

(_ => _.Date + " " +_.Time + _.Program).ToList();

<style>
.hiddenRow {
padding: 0 !important;
}

.in-line {
display: inline;
}
</style>
<br />

<table class="table table-condensed" style="border-collapse:collapse;">
<thead>
<tr>
<th>
<h3>TV-Tablå 2018-11-12</h3>
<b>Välj de kanaler du vill se tablån för</b>
</th>
<th>

</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" data-toggle="collapse" data-target="div
[id*='demo1']" /><b> SVT1</b>
</td>
</tr>
@for (var i = 0; i < @list1.Count; i++)
{
<tr>
<td colspan="2" class="hiddenRow">
<div id="demo1+'@i'+" class="accordian-body collapse">
@list1[i]
</div>
</td>
</tr>
}

<tr data-toggle="collapse" data-target="#demo2">
<td>
<input type="checkbox" data-toggle="collapse" data-target="div
[id*='demo2']" /><b> SVT2</b>
</td>
</tr>
@for (var i = 0; i < @list2.Count; i++)
{
<tr>
<td colspan="2" class="hiddenRow">
<div id="demo2+'@i'+" class="accordian-body collapse">
@list2[i]
</div>
</td>
</tr>
}

<tr data-toggle="collapse" data-target="#demo3">
<td>
<input type="checkbox" data-toggle="collapse" data-target="div
[id*='demo3']" /><b> TV3</b>
</td>
</tr>
@for (var i = 0; i < @list3.Count; i++)
{
<tr>
<td colspan="2" class="hiddenRow">
<div id="demo3+'@i'+" class="accordian-body collapse">
@list3[i]
</div>
</td>
</tr>
}

<tr data-toggle="collapse" data-target="#demo4">
<td>
<input type="checkbox" data-toggle="collapse" data-target="div
[id*='demo4']" /><b> TV4</b>
</td>
</tr>
@for (var i = 0; i < @list4.Count; i++)
{
<tr>
<td colspan="2" class="hiddenRow">
<div id="demo4+'@i'+" class="accordian-body collapse">
@list4[i]
</div>
</td>
</tr>
}

<tr data-toggle="collapse" data-target="#demo5">
<td>
<input type="checkbox" data-toggle="collapse" data-target="div
[id*='demo5']" /><b> Kanal5</b>
</td>
</tr>
@for (var i = 0; i < @list5.Count; i++)
{
<tr>
<td colspan="2" class="hiddenRow">
<div id="demo5+'@i'+" class="accordian-body collapse">
@list5[i]
</div>
</td>
</tr>
}
</tbody>
</table>


My model (from my database table Full with entity framework)



namespace Uppgift4.Models
{
using System;
using System.Collections.Generic;

public partial class Full
{
public int Id { get; set; }
public string Channel { get; set; }
public string Program { get; set; }
public string Category { get; set; }
public string Date { get; set; }
public string Time { get; set; }
public string Length { get; set; }
}
}









share|improve this question





























    0















    I have made an tv-guide where you can see the programs for 5 channels. If you login you can also make an "personal" tvguide. where you can decide which of the 5 channels you are interested in seeing the tableau of, by clicking on their checkboxes. How can I make the application remember the user input. So let's say I log in and open the menu for Channel one (SVT1), and two (SVT2). Then I want these two channels also to be open next time I log in with that user id, how do I do that?



    Screenshot of my personal tv-guide page



    My controller



    public class FavoritChannelsController : Controller
    {
    TvProgramDBEntities db = new TvProgramDBEntities();

    [Authorize(Roles = "User")]
    public ActionResult channel_index()
    {
    List<Full> model = new List<Full>();
    var list = db.Full.Where(d => d.Date == "2018-11-12").ToList();

    foreach (var item in list)
    {
    if (item.Id <1000)
    {
    var initedF = new Full
    {
    Channel = Regex.Replace(item.Channel, @"s", ""),
    Program = item.Program,
    Time = item.Time,
    Date = Regex.Replace(item.Date, @"s", "")
    };
    model.Add(initedF);
    }

    }
    return View(model);
    }
    }


    My view



    @model IEnumerable<Uppgift4.Models.Full>

    @{
    ViewBag.Title = "channel_Index";
    var list = Model.ToList();
    var list1 = list.Where(_ => _.Channel == "SVT1").Select(_ => _.Time +
    _.Program).ToList();
    var list2 = list.Where(_ => _.Channel == "SVT2").Select(_ => _.Time +
    _.Program).ToList();
    var list3 = list.Where(_ => _.Channel == "TV3").Select(_ => _.Time +
    _.Program).ToList();
    var list4 = list.Where(_ => _.Channel == "TV4").Select(_ => _.Time +
    _.Program).ToList();
    var list5 = list.Where(_ => _.Channel == "Kanal5").Select(_ => _.Time +
    _.Program).ToList();
    }

    (_ => _.Date + " " +_.Time + _.Program).ToList();

    <style>
    .hiddenRow {
    padding: 0 !important;
    }

    .in-line {
    display: inline;
    }
    </style>
    <br />

    <table class="table table-condensed" style="border-collapse:collapse;">
    <thead>
    <tr>
    <th>
    <h3>TV-Tablå 2018-11-12</h3>
    <b>Välj de kanaler du vill se tablån för</b>
    </th>
    <th>

    </th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>
    <input type="checkbox" data-toggle="collapse" data-target="div
    [id*='demo1']" /><b> SVT1</b>
    </td>
    </tr>
    @for (var i = 0; i < @list1.Count; i++)
    {
    <tr>
    <td colspan="2" class="hiddenRow">
    <div id="demo1+'@i'+" class="accordian-body collapse">
    @list1[i]
    </div>
    </td>
    </tr>
    }

    <tr data-toggle="collapse" data-target="#demo2">
    <td>
    <input type="checkbox" data-toggle="collapse" data-target="div
    [id*='demo2']" /><b> SVT2</b>
    </td>
    </tr>
    @for (var i = 0; i < @list2.Count; i++)
    {
    <tr>
    <td colspan="2" class="hiddenRow">
    <div id="demo2+'@i'+" class="accordian-body collapse">
    @list2[i]
    </div>
    </td>
    </tr>
    }

    <tr data-toggle="collapse" data-target="#demo3">
    <td>
    <input type="checkbox" data-toggle="collapse" data-target="div
    [id*='demo3']" /><b> TV3</b>
    </td>
    </tr>
    @for (var i = 0; i < @list3.Count; i++)
    {
    <tr>
    <td colspan="2" class="hiddenRow">
    <div id="demo3+'@i'+" class="accordian-body collapse">
    @list3[i]
    </div>
    </td>
    </tr>
    }

    <tr data-toggle="collapse" data-target="#demo4">
    <td>
    <input type="checkbox" data-toggle="collapse" data-target="div
    [id*='demo4']" /><b> TV4</b>
    </td>
    </tr>
    @for (var i = 0; i < @list4.Count; i++)
    {
    <tr>
    <td colspan="2" class="hiddenRow">
    <div id="demo4+'@i'+" class="accordian-body collapse">
    @list4[i]
    </div>
    </td>
    </tr>
    }

    <tr data-toggle="collapse" data-target="#demo5">
    <td>
    <input type="checkbox" data-toggle="collapse" data-target="div
    [id*='demo5']" /><b> Kanal5</b>
    </td>
    </tr>
    @for (var i = 0; i < @list5.Count; i++)
    {
    <tr>
    <td colspan="2" class="hiddenRow">
    <div id="demo5+'@i'+" class="accordian-body collapse">
    @list5[i]
    </div>
    </td>
    </tr>
    }
    </tbody>
    </table>


    My model (from my database table Full with entity framework)



    namespace Uppgift4.Models
    {
    using System;
    using System.Collections.Generic;

    public partial class Full
    {
    public int Id { get; set; }
    public string Channel { get; set; }
    public string Program { get; set; }
    public string Category { get; set; }
    public string Date { get; set; }
    public string Time { get; set; }
    public string Length { get; set; }
    }
    }









    share|improve this question



























      0












      0








      0








      I have made an tv-guide where you can see the programs for 5 channels. If you login you can also make an "personal" tvguide. where you can decide which of the 5 channels you are interested in seeing the tableau of, by clicking on their checkboxes. How can I make the application remember the user input. So let's say I log in and open the menu for Channel one (SVT1), and two (SVT2). Then I want these two channels also to be open next time I log in with that user id, how do I do that?



      Screenshot of my personal tv-guide page



      My controller



      public class FavoritChannelsController : Controller
      {
      TvProgramDBEntities db = new TvProgramDBEntities();

      [Authorize(Roles = "User")]
      public ActionResult channel_index()
      {
      List<Full> model = new List<Full>();
      var list = db.Full.Where(d => d.Date == "2018-11-12").ToList();

      foreach (var item in list)
      {
      if (item.Id <1000)
      {
      var initedF = new Full
      {
      Channel = Regex.Replace(item.Channel, @"s", ""),
      Program = item.Program,
      Time = item.Time,
      Date = Regex.Replace(item.Date, @"s", "")
      };
      model.Add(initedF);
      }

      }
      return View(model);
      }
      }


      My view



      @model IEnumerable<Uppgift4.Models.Full>

      @{
      ViewBag.Title = "channel_Index";
      var list = Model.ToList();
      var list1 = list.Where(_ => _.Channel == "SVT1").Select(_ => _.Time +
      _.Program).ToList();
      var list2 = list.Where(_ => _.Channel == "SVT2").Select(_ => _.Time +
      _.Program).ToList();
      var list3 = list.Where(_ => _.Channel == "TV3").Select(_ => _.Time +
      _.Program).ToList();
      var list4 = list.Where(_ => _.Channel == "TV4").Select(_ => _.Time +
      _.Program).ToList();
      var list5 = list.Where(_ => _.Channel == "Kanal5").Select(_ => _.Time +
      _.Program).ToList();
      }

      (_ => _.Date + " " +_.Time + _.Program).ToList();

      <style>
      .hiddenRow {
      padding: 0 !important;
      }

      .in-line {
      display: inline;
      }
      </style>
      <br />

      <table class="table table-condensed" style="border-collapse:collapse;">
      <thead>
      <tr>
      <th>
      <h3>TV-Tablå 2018-11-12</h3>
      <b>Välj de kanaler du vill se tablån för</b>
      </th>
      <th>

      </th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo1']" /><b> SVT1</b>
      </td>
      </tr>
      @for (var i = 0; i < @list1.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo1+'@i'+" class="accordian-body collapse">
      @list1[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo2">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo2']" /><b> SVT2</b>
      </td>
      </tr>
      @for (var i = 0; i < @list2.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo2+'@i'+" class="accordian-body collapse">
      @list2[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo3">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo3']" /><b> TV3</b>
      </td>
      </tr>
      @for (var i = 0; i < @list3.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo3+'@i'+" class="accordian-body collapse">
      @list3[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo4">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo4']" /><b> TV4</b>
      </td>
      </tr>
      @for (var i = 0; i < @list4.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo4+'@i'+" class="accordian-body collapse">
      @list4[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo5">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo5']" /><b> Kanal5</b>
      </td>
      </tr>
      @for (var i = 0; i < @list5.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo5+'@i'+" class="accordian-body collapse">
      @list5[i]
      </div>
      </td>
      </tr>
      }
      </tbody>
      </table>


      My model (from my database table Full with entity framework)



      namespace Uppgift4.Models
      {
      using System;
      using System.Collections.Generic;

      public partial class Full
      {
      public int Id { get; set; }
      public string Channel { get; set; }
      public string Program { get; set; }
      public string Category { get; set; }
      public string Date { get; set; }
      public string Time { get; set; }
      public string Length { get; set; }
      }
      }









      share|improve this question
















      I have made an tv-guide where you can see the programs for 5 channels. If you login you can also make an "personal" tvguide. where you can decide which of the 5 channels you are interested in seeing the tableau of, by clicking on their checkboxes. How can I make the application remember the user input. So let's say I log in and open the menu for Channel one (SVT1), and two (SVT2). Then I want these two channels also to be open next time I log in with that user id, how do I do that?



      Screenshot of my personal tv-guide page



      My controller



      public class FavoritChannelsController : Controller
      {
      TvProgramDBEntities db = new TvProgramDBEntities();

      [Authorize(Roles = "User")]
      public ActionResult channel_index()
      {
      List<Full> model = new List<Full>();
      var list = db.Full.Where(d => d.Date == "2018-11-12").ToList();

      foreach (var item in list)
      {
      if (item.Id <1000)
      {
      var initedF = new Full
      {
      Channel = Regex.Replace(item.Channel, @"s", ""),
      Program = item.Program,
      Time = item.Time,
      Date = Regex.Replace(item.Date, @"s", "")
      };
      model.Add(initedF);
      }

      }
      return View(model);
      }
      }


      My view



      @model IEnumerable<Uppgift4.Models.Full>

      @{
      ViewBag.Title = "channel_Index";
      var list = Model.ToList();
      var list1 = list.Where(_ => _.Channel == "SVT1").Select(_ => _.Time +
      _.Program).ToList();
      var list2 = list.Where(_ => _.Channel == "SVT2").Select(_ => _.Time +
      _.Program).ToList();
      var list3 = list.Where(_ => _.Channel == "TV3").Select(_ => _.Time +
      _.Program).ToList();
      var list4 = list.Where(_ => _.Channel == "TV4").Select(_ => _.Time +
      _.Program).ToList();
      var list5 = list.Where(_ => _.Channel == "Kanal5").Select(_ => _.Time +
      _.Program).ToList();
      }

      (_ => _.Date + " " +_.Time + _.Program).ToList();

      <style>
      .hiddenRow {
      padding: 0 !important;
      }

      .in-line {
      display: inline;
      }
      </style>
      <br />

      <table class="table table-condensed" style="border-collapse:collapse;">
      <thead>
      <tr>
      <th>
      <h3>TV-Tablå 2018-11-12</h3>
      <b>Välj de kanaler du vill se tablån för</b>
      </th>
      <th>

      </th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo1']" /><b> SVT1</b>
      </td>
      </tr>
      @for (var i = 0; i < @list1.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo1+'@i'+" class="accordian-body collapse">
      @list1[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo2">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo2']" /><b> SVT2</b>
      </td>
      </tr>
      @for (var i = 0; i < @list2.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo2+'@i'+" class="accordian-body collapse">
      @list2[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo3">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo3']" /><b> TV3</b>
      </td>
      </tr>
      @for (var i = 0; i < @list3.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo3+'@i'+" class="accordian-body collapse">
      @list3[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo4">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo4']" /><b> TV4</b>
      </td>
      </tr>
      @for (var i = 0; i < @list4.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo4+'@i'+" class="accordian-body collapse">
      @list4[i]
      </div>
      </td>
      </tr>
      }

      <tr data-toggle="collapse" data-target="#demo5">
      <td>
      <input type="checkbox" data-toggle="collapse" data-target="div
      [id*='demo5']" /><b> Kanal5</b>
      </td>
      </tr>
      @for (var i = 0; i < @list5.Count; i++)
      {
      <tr>
      <td colspan="2" class="hiddenRow">
      <div id="demo5+'@i'+" class="accordian-body collapse">
      @list5[i]
      </div>
      </td>
      </tr>
      }
      </tbody>
      </table>


      My model (from my database table Full with entity framework)



      namespace Uppgift4.Models
      {
      using System;
      using System.Collections.Generic;

      public partial class Full
      {
      public int Id { get; set; }
      public string Channel { get; set; }
      public string Program { get; set; }
      public string Category { get; set; }
      public string Date { get; set; }
      public string Time { get; set; }
      public string Length { get; set; }
      }
      }






      asp.net-mvc authentication model-view-controller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 11:03









      marc_s

      573k12811071254




      573k12811071254










      asked Nov 24 '18 at 10:47









      MichaelMichael

      72




      72
























          1 Answer
          1






          active

          oldest

          votes


















          0














          By using following Command you can Get the UserId of the current user in controllers.



          using Microsoft.AspNet.Identity;


          .


          .


          .



          User.Identity.GetUserId()


          Use this Id to save/retrieve user choices. For example you can add following entity.



          public class User_Channel
          {
          public int User_ChannelId { get; set; }
          [MaxLength(128)]
          public string UserId { get; set; }
          public int ChannelId { get; set; }
          }





          share|improve this answer
























          • Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

            – Michael
            Nov 25 '18 at 10:47











          • hi, yes you should save checkbox value. check this link

            – vahid
            Nov 25 '18 at 13:34











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457353%2fhow-to-save-the-settings-of-an-authentication-id-in-asp-net-mvc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          By using following Command you can Get the UserId of the current user in controllers.



          using Microsoft.AspNet.Identity;


          .


          .


          .



          User.Identity.GetUserId()


          Use this Id to save/retrieve user choices. For example you can add following entity.



          public class User_Channel
          {
          public int User_ChannelId { get; set; }
          [MaxLength(128)]
          public string UserId { get; set; }
          public int ChannelId { get; set; }
          }





          share|improve this answer
























          • Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

            – Michael
            Nov 25 '18 at 10:47











          • hi, yes you should save checkbox value. check this link

            – vahid
            Nov 25 '18 at 13:34
















          0














          By using following Command you can Get the UserId of the current user in controllers.



          using Microsoft.AspNet.Identity;


          .


          .


          .



          User.Identity.GetUserId()


          Use this Id to save/retrieve user choices. For example you can add following entity.



          public class User_Channel
          {
          public int User_ChannelId { get; set; }
          [MaxLength(128)]
          public string UserId { get; set; }
          public int ChannelId { get; set; }
          }





          share|improve this answer
























          • Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

            – Michael
            Nov 25 '18 at 10:47











          • hi, yes you should save checkbox value. check this link

            – vahid
            Nov 25 '18 at 13:34














          0












          0








          0







          By using following Command you can Get the UserId of the current user in controllers.



          using Microsoft.AspNet.Identity;


          .


          .


          .



          User.Identity.GetUserId()


          Use this Id to save/retrieve user choices. For example you can add following entity.



          public class User_Channel
          {
          public int User_ChannelId { get; set; }
          [MaxLength(128)]
          public string UserId { get; set; }
          public int ChannelId { get; set; }
          }





          share|improve this answer













          By using following Command you can Get the UserId of the current user in controllers.



          using Microsoft.AspNet.Identity;


          .


          .


          .



          User.Identity.GetUserId()


          Use this Id to save/retrieve user choices. For example you can add following entity.



          public class User_Channel
          {
          public int User_ChannelId { get; set; }
          [MaxLength(128)]
          public string UserId { get; set; }
          public int ChannelId { get; set; }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 13:32









          vahidvahid

          1364




          1364













          • Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

            – Michael
            Nov 25 '18 at 10:47











          • hi, yes you should save checkbox value. check this link

            – vahid
            Nov 25 '18 at 13:34



















          • Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

            – Michael
            Nov 25 '18 at 10:47











          • hi, yes you should save checkbox value. check this link

            – vahid
            Nov 25 '18 at 13:34

















          Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

          – Michael
          Nov 25 '18 at 10:47





          Hi. Thx for input. Cant really get it right, can you please show how to use this more specifik, guess i need to save the checkbox value somehow. example is Always good :-) #vahid

          – Michael
          Nov 25 '18 at 10:47













          hi, yes you should save checkbox value. check this link

          – vahid
          Nov 25 '18 at 13:34





          hi, yes you should save checkbox value. check this link

          – vahid
          Nov 25 '18 at 13:34


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457353%2fhow-to-save-the-settings-of-an-authentication-id-in-asp-net-mvc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)