title: MVC repository and interface returning Json
body: <p>I'm new at MVC and can't get this to work.  I basically have a Users class, a UserRepository, and a IUser interface.  </p>
  
  <p>This is my code:</p>
  
  <pre><code>public class Users
  {
  
  public string UserName { get; set; }
  public string Department { get; set; }
  public string UserType { get; set; }
  
  
  }
  
   public class UsersRepository : TimeAttendanceMVC.Models.IUsers
  {
  
      public Users Return_UserName_Dept()
      {
          Users U = new Users();
          List&lt;Users&gt; LoggedInUser = new List&lt;Users&gt;();
  
          U.UserName = "TestUser";
          U.Department = "Finance";
          U.UserType = "Administrator";
  
          LoggedInUser.Add(U);
  
          //string json = JsonConvert.SerializeObject(LoggedInUser, Formatting.Indented);
          //return json;
  
          return Json(LoggedInUser.ToArray(), JsonRequestBehavior.AllowGet);
  
      }
  
  
  }
  
  namespace TimeAttendanceMVC.Models
  {
    public  class IUsers
      {
        List&lt;Users&gt; Return_UserName_Dept();
  
      }
  }
  </code></pre>
  
  <p>There are a few errors that I get.  In UsersRepository.cs where i'm returning Json, the error says that "The name Json does not exist in the current context".  The error from IUsers.cs is that "Return_UserName_Dept() must declare a body because it is not marked abstract...".</p>
  
  <p>Can anybody please help me with this.  I just don't know how this is supposed to work and i'm trying to learn MVC by working on this application.  It's actually the FullCalendar application found here -  <a href="http://arshaw.com/fullcalendar/" rel="nofollow">link to FullCalendar</a>.  I'm trying to turn it into an MVC application.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Maybe I need to do this:</p>
  
  <p>public JsonResult Return_UserName_Dept() </p>
  
  <p>instead of public Users Return_UserName_Dept()</p>