public static void SubmitNewsVark(NewsVark item) { using (var ctx = new RentooloEntities()) { if (item.Id == 0) { ctx.NewsVark.Add(item); } else { var obj = ctx.NewsVark.Single(x => x.Id == item.Id); obj.Date = item.Date; obj.Text = item.Text; obj.CreateDate = item.CreateDate; obj.AuthorId = item.AuthorId; obj.Active = item.Active; } try { ctx.SaveChanges(); } catch (System.Exception ex) { DataHelper.AddException(ex); } } }
public static void DeleteNewsVark(int id) { using (var ctx = new RentooloEntities()) { NewsVark obj = ctx.NewsVark.Single(x => x.Id == id); ctx.NewsVark.Remove(obj); try { ctx.SaveChanges(); } catch (System.Exception ex) { DataHelper.AddException(ex); } } }