public void Update(Kichthuoc_Model model) { var data = Connect_Enttity.Kichthuocs.FirstOrDefault(x => x.ID == model.ID); if (data != null) { data.Kichthuoc1 = model.Kichthuoc1; data.Vitri = (int)(model.Vitri); data.Active = (bool)(model.Active); Connect_Enttity.SaveChanges(); Dispose(); } }
public IList <Kichthuoc_Model> GetId(Kichthuoc_Model model) { IList <Kichthuoc_Model> result = new List <Kichthuoc_Model>(); result = Connect_Enttity.Kichthuocs.Where(x => x.ID == model.ID).Select(x => new Kichthuoc_Model { ID = x.ID, Kichthuoc1 = x.Kichthuoc1, Vitri = (int)(x.Vitri), Active = (bool)(x.Active) }).ToList(); return(result); }
public void Create(Kichthuoc_Model model) { var data = Connect_Enttity.Kichthuocs.FirstOrDefault(x => x.ID == model.ID); if (data == null) { var entity = new Kichthuoc(); entity.Kichthuoc1 = model.Kichthuoc1; entity.Vitri = (int)(model.Vitri); entity.Active = (bool)(model.Active); Connect_Enttity.Kichthuocs.Add(entity); Connect_Enttity.SaveChanges(); Dispose(); } }
[Authorize(Roles = "Admin")] //Personnel public ActionResult Insert(string Kichco_Size, string Active, string Ord) { Kichthuoc_Model data = new Kichthuoc_Model();//gọi model data data.Kichthuoc1 = Kichco_Size; data.Active = Convert.ToBoolean(Active); data.Vitri = Convert.ToInt32(Ord); if (connect_entity.Kichthuocs.FirstOrDefault (x => x.Kichthuoc1 == Kichco_Size) == 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 <Kichthuoc_Model> ReadID(Kichthuoc_Model model) { return(GetId(model)); }