public void Update(quantity_purchased_Model model)
        {
            var data = Connect_Enttity.quantity_purchased.FirstOrDefault(x => x.Id_quantity == model.Id_quantity);

            if (data != null)
            {
                data.Sl_mua         = (int)(model.Sl_mua);
                data.Phan_tram_tang = (int)(model.Phan_tram_tang);
                data.Active         = (bool)(model.Active);

                Connect_Enttity.SaveChanges();
                Dispose();
            }
        }
        public IList <quantity_purchased_Model> GetId(quantity_purchased_Model model)
        {
            IList <quantity_purchased_Model> result = new List <quantity_purchased_Model>();

            result = Connect_Enttity.quantity_purchased.Where(x => x.Id_quantity == model.Id_quantity).Select(x => new quantity_purchased_Model
            {
                Id_quantity    = x.Id_quantity,
                Sl_mua         = (int)(x.Sl_mua),
                Phan_tram_tang = (int)(x.Phan_tram_tang),
                Active         = (bool)(x.Active)
            }).ToList();

            return(result);
        }
        [Authorize(Roles = "Admin")]  //Personnel
        public ActionResult Insert(int Sl_mua, string Phan_tram_tang, string Active)
        {
            quantity_purchased_Model data = new quantity_purchased_Model();//gọi model data

            data.Sl_mua         = Convert.ToInt32(Sl_mua);
            data.Phan_tram_tang = Convert.ToInt32(Phan_tram_tang);
            data.Active         = Convert.ToBoolean(Active);

            if (connect_entity.quantity_purchased.FirstOrDefault
                    (x => x.Sl_mua == Sl_mua) == null) // kiểm tra không được trùng tên
            {
                Connect.Create(data);                  //gọi service lưu
                Resurt = 1;
            }
            else
            {
                Resurt = 0;
            }
            return(Json(Resurt, JsonRequestBehavior.AllowGet));
        }
 public IEnumerable <quantity_purchased_Model> ReadID(quantity_purchased_Model model)
 {
     return(GetId(model));
 }