public ActionResult Create(IEnumerable <lokasi_sampling> models) { List <GraphicLokasiSamplingWrapper> ss = new List <GraphicLokasiSamplingWrapper>(); //Iterate all created products which are posted by the Kendo Grid foreach (var source in models) { // Create a new Product entity and set its properties from productViewModel var s = new lokasi_sampling { lokasi_sampling1 = source.lokasi_sampling1, type = source.type }; db.lokasi_sampling.Add(s); db.SaveChanges(); GraphicTypeWrapper ls = db.graphic_type.Select(p => new GraphicTypeWrapper { id = p.id, name = p.name }).Where(p => p.id == source.type).FirstOrDefault(); // store the product in the result ss.Add(new GraphicLokasiSamplingWrapper { id = s.id, lokasi_sampling1 = s.lokasi_sampling1, type = s.type, graphic_type = ls }); } return(Json(ss.ToList())); }
public ActionResult Delete(IEnumerable <lokasi_sampling> models) { foreach (var source in models) { // Create a new Product entity and set its properties from productViewModel lokasi_sampling s = db.lokasi_sampling.Find(source.id); db.lokasi_sampling.Remove(s); db.SaveChanges(); } return(Json(null)); }
public ActionResult Edit(IEnumerable <lokasi_sampling> models) { foreach (var source in models) { // Create a new Product entity and set its properties from productViewModel lokasi_sampling s = db.lokasi_sampling.Find(source.id); s.lokasi_sampling1 = source.lokasi_sampling1; s.type = source.type; db.Entry(s).State = EntityState.Modified; db.SaveChanges(); } return(Json(null)); }