//
        // GET: /Materials/Create
        public ActionResult Get(Page model)
        {
            using (AppDB db = new AppDB())
            {

                return Json(IEnumerableData.GetPageResponse<MaterialModel>(model, (from m in db.Materials
                                                                                   join s in db.Sellers on m.SellerId equals s.Id
                                                                                   join o in db.Orders on m.OrderId equals o.Id
                                                                                   join u in db.Employees on m.CreatedBy equals u.Id
                                                                                   where m.OrderId == model.id
                                                                                   select new MaterialModel() {
                                                                                    Id=m.Id,
                                                                                    SellerId=m.SellerId,
                                                                                    Seller=s.Name,
                                                                                    OrderId = m.OrderId,
                                                                                    Order=o.CodeNumber,
                                                                                    Amount = m.Amount,
                                                                                    Description = m.Description,
                                                                                    OrderDate = m.OrderDate,
                                                                                    DeliveryDate = m.DeliveryDate,
                                                                                    CreatedBy = m.CreatedBy,
                                                                                    CreatedByName=u.Name,
                                                                                    ReceivedDate = m.ReceivedDate
                                                                                   })), JsonRequestBehavior.AllowGet);
            }
        }
 public ActionResult Get(Page model)
 {
     ResponseJson response = new ResponseJson() { Data = new List<object>() };
     var data = new Pagger<dynamic>();
     using (AppDB db = new AppDB())
     {
         response = IEnumerableData.GetPageResponse<BundleModel>(model, (from b in db.Bundles
                                                                         join s in db.Styles on b.StyleId equals s.Id
                                                                         join st in db.Status on b.Status equals st.Id
                                                                         join o in db.Employees on b.OperatorId equals o.Id
                                                                         join l in db.Employees on b.LinkingBy equals l.Id
                                                                         where b.Status == 2
                                                                         select new BundleModel()
                                                                         {
                                                                             BarCode = b.BarCode,
                                                                             Style = s.Name,
                                                                             StyleId = b.StyleId,
                                                                             Id = b.Id,
                                                                             Quantity = b.Quantity,
                                                                             Status = st.Name,
                                                                             StatusId = st.Id,
                                                                             KnittingMachine = b.KnittingMachine,
                                                                             LinkingEndAt = b.LinkingEndAt,
                                                                             OperatorId = b.OperatorId,
                                                                             Operator = o.Name,
                                                                             LinkingBy = l.Name,
                                                                             LinkingById = l.Id
                                                                         }));
     }
     return Json(response, JsonRequestBehavior.AllowGet);
 }
 public ActionResult Get(Page model)
 {
     ResponseJson response = new ResponseJson() { Data = new List<object>() };
     var data = new Pagger<dynamic>();
     using (AppDB db = new AppDB())
     {
         response = IEnumerableData.GetPageResponse<StyleModel>(model, (from s in db.Styles
                                                                             join b in db.Buyers on s.BuyerId equals b.Id
                                                                             join st in db.Status on s.Status equals st.Id
                                                                             select new StyleModel() {
                                                                                 BarCode=s.BarCode,
                                                                                 Buyer=b.Name,
                                                                                 BuyerId=s.BuyerId,
                                                                                 Id=s.Id,
                                                                                 Name=s.Name,
                                                                                 Quantity=s.Quantity,
                                                                                 Status=st.Name,
                                                                                 StatusId=st.Id,
                                                                                 ShippingDate=s.ShippingDate,
                                                                                 Description=s.Description,
                                                                                 YarnType=s.YarnType,
                                                                                 Size=s.Size,
                                                                             }));
     }
     return Json(response, JsonRequestBehavior.AllowGet);
 }
        public ActionResult Get(Page model)
        {
            ResponseJson response = new ResponseJson() { Data = new List<object>() };

            using (AppDB db = new AppDB())
            {
                response = IEnumerableData.GetPageResponse<BuyerModel>(model, (from b in db.Buyers
                                                                               select new BuyerModel()
                                                                                  {
                                                                                      Id = b.Id,
                                                                                      Name = b.Name,
                                                                                      Phone = b.Phone,
                                                                                      Email = b.Email,
                                                                                      Address = b.Address,
                                                                                      CreatedAt = b.CreatedAt
                                                                                  }));
            }
            return Json(response, JsonRequestBehavior.AllowGet);
        }
 //
 // GET: /Buyers/Details/
 public ActionResult Index(Page model)
 {
     ViewBag.Page = new JavaScriptSerializer().Serialize(model);
     return View(CurrentUser);
 }
        public ActionResult Get(Page model)
        {
            ResponseJson response = new ResponseJson() { Data = new List<object>() };
              using (AppDB db = new AppDB())
              {
            response = IEnumerableData.GetPageResponse<OrderModel>(model, (from o in db.Orders
                                                                       join b in db.Buyers on o.BuyerId equals b.Id
                                                                       where o.Status != 10
                                                                       select new OrderModel()
                                                                       {
                                                                         Id = o.Id,
                                                                         Buyer = b.Name,
                                                                         BuyerId = o.BuyerId,
                                                                         CodeNumber = o.CodeNumber,
                                                                         Color = o.Color,
                                                                         DeliveryDate = o.DeliveryDate,
                                                                         Description = o.Description,
                                                                         Size = o.Size,
                                                                         Style = o.Style,
                                                                         Quantity = o.TotalQuantity,
                                                                         Completed = o.TotalCompleted,
                                                                         ProductionStartAT = o.ProductionStartAT,
                                                                         OrderDate = o.OrderDate,
                                                                         CurrentDate = DateTime.Now
                                                                       }).ToList());

              }
              return Json(response, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Get(Page model)
        {
            ResponseJson response = new ResponseJson() { Data = new List<object>() };

              using (AppDB db = new AppDB())
              {
            var currentRole = db.Roles.Where(r => CurrentUser.Roles.Contains(r.Code)).Min(r => r.Priority);
            response = IEnumerableData.GetPageResponse<EmployeeModel>(model, (from b in db.Employees
                                                                          join
                                                                          r in db.Roles on b.Role equals r.Code
                                                                          where r.Priority > currentRole
                                                                          select new EmployeeModel()
                                                                        {
                                                                          Id = b.Id,
                                                                          BarCode = b.BarCode,
                                                                          Name = b.Name,
                                                                          Phone = b.Phone,
                                                                          Email = b.Email,
                                                                          Address = b.Address,
                                                                          Role = r.Name,
                                                                          CreatedAt = b.CreatedAt,
                                                                          IsActive = b.IsActive
                                                                        }));
              }
              return Json(response, JsonRequestBehavior.AllowGet);
        }