public ActionResult Weredas_Create([DataSourceRequest] DataSourceRequest request, Wereda wereda) { if (ModelState.IsValid) { var entity = new Wereda { Code = wereda.Code, Name = wereda.Name, SubcityId = wereda.SubcityId, Description = wereda.Description, Remark = wereda.Remark }; db.Weredas.Add(entity); db.SaveChanges(); wereda.WeredaId = entity.WeredaId; } return(Json(new[] { wereda }.ToDataSourceResult(request, ModelState))); }
public ActionResult Weredas_Update([DataSourceRequest] DataSourceRequest request, Wereda wereda) { if (ModelState.IsValid) { var entity = new Wereda { WeredaId = wereda.WeredaId, Code = wereda.Code, Name = wereda.Name, SubcityId = wereda.SubcityId, Description = wereda.Description, Remark = wereda.Remark }; db.Weredas.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { wereda }.ToDataSourceResult(request, ModelState))); }