public int CreateEditSalient(SalientFeature entity) { if (entity.ID == 0) { db.SalientFeatures.Add(entity); try { db.SaveChanges(); return(1); } catch (Exception) { throw; } } else if (entity.ID != 0) { var salient = db.SalientFeatures.Find(entity.ID); salient.Name = entity.Name; salient.Status = entity.Status; try { db.SaveChanges(); return(2); } catch (Exception) { throw; } } else { return(0); } }
public bool?ChangeStatus(int Id) { SalientFeature entity = db.SalientFeatures.Find(Id); entity.Status = !entity.Status; db.SaveChanges(); return(entity.Status); }
public JsonResult CreateEditSalient(string strSalient) { JavaScriptSerializer serializer = new JavaScriptSerializer(); SalientFeature entity = serializer.Deserialize <SalientFeature>(strSalient); SalientFeatureDAO dao = new SalientFeatureDAO(); int res = dao.CreateEditSalient(entity); return(Json(new { res = res })); }
public int DeleteSalient(int Id) { SalientFeature entity = db.SalientFeatures.Find(Id); db.SalientFeatures.Remove(entity); try { db.SaveChanges(); return(1); } catch (Exception) { return(0); } }