0

I have two model in my project, SupplierRow.cs

 using System;

 namespace Argussite.SupplierServices.ViewModels
 {
public class SupplierRow
  {
    public Guid Id { get; set; }
    public string FullName { get; set; }
    public bool Subscribed { get; set; }

    public bool Active { get; set; }
    public int Visits { get; set; }
  }
}

and UserRow.cs

using System;

namespace Argussite.SupplierServices.ViewModels
{
public class UserRow
    {
    public Guid Id { get; set; }
    public string FullName { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
    public int Status { get; set; }
    public int Role { get; set; }
    }
}     

then I use the first model in one controller

 public ActionResult Grid(bool? active)
    {
        var page = Context.Suppliers.AsNoTracking()
            .WhereIf(active != null, e => e.Active == active)
            .Select(e => new SupplierRow
                            {
                                Id = e.Id,
                                FullName = e.FullName,
                                Active = e.Active,
                                Visits = e.Visits
                            })
                            .ToList();

        return PartialView("_Grid", page);
    }

and use the second model in other controller

 public class AdminSuppliersAccountsController : BaseController
{
    public ActionResult Index(Guid id)
    {
        var supplierOfUser = Context.Suppliers.AsNoTracking()
            //.Include(e => e.Supplier)
            .FirstOrDefault(e => e.Id == id);


        ViewData.Add("id", id);
        ViewData.Add("SupplierFullName", supplierOfUser.FullName);
        return View();
    }

    public ActionResult Grid(int? status, Pager pager, Guid? supplierId)
    {
        var page = Context.Users.AsNoTracking()
            .Where(e => e.SupplierId == supplierId)
            .WhereIf(status != null, e => (e.Status == status))
            .Select(e => new UserRow
            {
                Id = e.Id,
                FullName = e.FullName,
                Email = e.Email,
                Name = e.Name,
                Status = e.Status,
                Role = e.Role
            })
            .GetPage(pager, Sorter.Asc<UserRow, string>(e => e.FullName));

        return PartialView("_Grid", page);
    }

but I need to add in the first controller checking if all users from second model have status Inactive and then use that in the view.
How can I do that?
I guess, I need to add a new property in the first model public bool AllUnactive { get; set; } but what should I do then?

4

0 回答 0