public bool Add(tblNewsLetter obj) { try { repository.tblNewsLetters.Add(obj); repository.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public JsonResult Active(int id) { tblNewsLetter ad = dc.tblNewsLetters.SingleOrDefault(ob => ob.NewsLetterId == id); if (ad.IsSubscribed == true) { ad.IsSubscribed = false; } else { ad.IsSubscribed = true; } dc.SaveChanges(); return(Json(ad.IsSubscribed, JsonRequestBehavior.AllowGet)); }
public bool Delete(int id) { try { tblNewsLetter result = Get(id); if (result != null) { result.Deleted = true; repository.SaveChanges(); return(true); } return(false); } catch (Exception) { return(false); } }
public bool Update(tblNewsLetter obj) { try { tblNewsLetter result = Get(obj.NewsId); if (result != null) { repository.Entry(result).CurrentValues.SetValues(obj); repository.SaveChanges(); return(true); } return(false); } catch (Exception) { return(false); } }