public void Delete(DalPost entity) { var temp = _context.Posts.Find(entity.PostId); _context.Posts.Remove(temp); _context.SaveChanges(); }
public void Update(DalPost entity) { var temp = _context.Posts.Find(entity.PostId); temp = Mapper.CreateMap().Map <Post>(entity); _context.SaveChanges(); }
public static PostEntity ToBllPost(this DalPost dalPost) { return(new PostEntity() { Id = dalPost.Id, Text = dalPost.Text }); }
public static Task <PostEntity> ToBllPostTask(this DalPost dalPost) { return(new Task <PostEntity>(() => new PostEntity() { Id = dalPost.Id, Name = dalPost.Name, Text = dalPost.Text, CreatedOn = dalPost.CreatedOn })); }
public static PostEntity ToBllPost(this DalPost dalPost) { return(new PostEntity() { Id = dalPost.Id, Name = dalPost.Name, Text = dalPost.Text, CreatedOn = dalPost.CreatedOn }); }
public static BllPost ToBll(this DalPost post) { return(new BllPost { Id = post.Id, Content = post.Content, Title = post.Title, BlogId = post.BlogId }); }
public DalPost GetPostUser(DalUser user) { DalPost UserLoginPost = null; using (Shop shop = new Shop()) { User tmpUser = shop.Users.Where(x => x.Id == user.Id).First(); UserLoginPost = EntityConvertToDTO.PostToDalPost(tmpUser.Post); }; return(UserLoginPost); }
public void Update(DalPost post) { NullRefCheck(); ArgumentNullCheck(post); var postDB = context.Set <Post>().FirstOrDefault(p => p.PostId == post.Id); postDB.Name = post.Name; postDB.Body = post.Body; postDB.SectionId = post.SectionId; postDB.DateOfCreation = post.DateOfPost; }
public void Delete(DalPost entity) { var post = new Post() { Text = entity.Text, CreatedOn = entity.CreatedOn, Name = entity.Name }; post = context.Set <Post>().Single(pst => pst.Id == entity.Id); context.Set <Post>().Remove(post); }
public void Create(DalPost entity) { var post = new Post { Id = entity.Id, Name = entity.Name, Text = entity.Text, CreatedOn = entity.CreatedOn }; context.Set <Post>().Add(post); }
public bool Pay(DalPost post) { try { _context.Posts.Add(Mapper.CreateMap().Map <Post>(post)); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public void Create(DalPost p) { NullRefCheck(); ArgumentNullCheck(p); var post = new Post() { PostId = p.Id, Name = p.Name, Body = p.Body, DateOfCreation = DateTime.Now, UserID = p.AuthorId, SectionId = p.SectionId }; context.Set <Post>().Add(post); }
public void Update(DalPost entity) { var actualPost = GetById(entity.Id); Post updatedPost = new Post() { Id = actualPost.Id, Name = actualPost.Name, Text = actualPost.Text }; context.Set <Post>().Attach(updatedPost); var post = context.Entry(updatedPost); post.Property(p => p.Name).IsModified = true; post.Property(p => p.Text).IsModified = true; context.SaveChanges(); }
public void Delete(DalPost p) { NullRefCheck(); ArgumentNullCheck(p); var post = new Post() { PostId = p.Id, Name = p.Name, Body = p.Body, DateOfCreation = p.DateOfPost, UserID = p.AuthorId, SectionId = p.SectionId }; post = context.Set <Post>().Single(u => u.PostId == post.PostId); context.Set <Post>().Remove(post); }
public static PostEntity ToBllPost(this DalPost dalPost) { return(new PostEntity() { Id = dalPost.Id, Name = dalPost.Name, Body = dalPost.Body, AuthorLogin = dalPost.AuthorLogin, AmountMessages = dalPost.AmountMessages, PostMessage = dalPost.PostMessage.Select(m => new MessageEntity() { AuthorLogin = m.AuthorLogin, Body = m.Body, DateOfMessage = m.DateOfMessage, Id = m.Id, PostID = m.PostID }), DateOfPost = dalPost.DateOfPost, AuthorId = dalPost.AuthorId, SectionId = dalPost.SectionId }); }
public void Insert(DalPost entity) { _context.Posts.Add(Mapper.CreateMap().Map <Post>(entity)); _context.SaveChanges(); }