public void Insert(MessageBindingModel model) { using (var context = new ForumDatabase()) { context.Message.Add(CreateModel(model, new Message())); context.SaveChanges(); } }
public void Insert(TopicBindingModel model) { using (var context = new ForumDatabase()) { context.Topic.Add(CreateModel(model, new Topic())); context.SaveChanges(); } }
public void Insert(VisitorBindingModel model) { using (var context = new ForumDatabase()) { Visitor visitor = CreateModel(model, new Visitor()); context.Visitor.Add(visitor); context.SaveChanges(); } }
public void Insert(ModeratorBindingModel model) { using (var context = new ForumDatabase()) { Moderator moder = CreateModel(model, new Moderator()); context.Moderator.Add(moder); context.SaveChanges(); } }
public void Update(VisitorBindingModel model) { using (var context = new ForumDatabase()) { var visitor = context.Visitor.FirstOrDefault(rec => rec.Login == model.LoginUser); if (visitor == null) { throw new Exception("Элемент не найден"); } CreateModel(model, visitor); context.SaveChanges(); } }
public void Update(MessageBindingModel model) { using (var context = new ForumDatabase()) { var element = context.Message.FirstOrDefault(rec => rec.Id == model.Id); if (element == null) { throw new Exception("Элемент не найден"); } CreateModel(model, element); context.SaveChanges(); } }
public void Update(LikeBindingModel model) { using (var context = new ForumDatabase()) { var element = context.Like.FirstOrDefault(rec => rec.Visitorlogin == model.LoginUser && rec.Messageid == model.IdMessage); if (element == null) { throw new Exception("Элемент не найден"); } CreateModel(model, element); context.SaveChanges(); } }
public void Delete(VisitorBindingModel model) { using (var context = new ForumDatabase()) { var element = context.Visitor.FirstOrDefault(rec => rec.Login == model.LoginUser); if (element != null) { context.Visitor.Remove(element); context.SaveChanges(); } else { throw new Exception("Элемент не найден"); } } }
public void Delete(MessageBindingModel model) { using (var context = new ForumDatabase()) { var element = context.Message.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Message.Remove(element); context.SaveChanges(); } else { throw new Exception("Элемент не найден"); } } }
/// <summary> /// Metoda finalizujaca transakcje. /// </summary> public void Complete() { context.SaveChanges(); }