public IHttpActionResult PutWallPostTagsTable(int id, WallPostTagsTable wallPostTagsTable)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != wallPostTagsTable.Id)
            {
                return BadRequest();
            }

            db.Entry(wallPostTagsTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WallPostTagsTableExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostWallPostTagsTable(WallPostTagsTable wallPostTagsTable)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.WallPostTagsTables.Add(wallPostTagsTable);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = wallPostTagsTable.Id }, wallPostTagsTable);
        }
Example #3
0
        public static Wall ParseWallModelToEntity(WallModel model)
        {
            var entity = new Wall();
            entity.Id = model.Id;
            entity.UserId = model.Id;
            entity.PosterId = model.Id;
            entity.Message = model.Message;
            entity.Picture = model.Picture;
            entity.PostTime = model.PostTime;

            foreach (var m in model.PostTags)
            {
                WallPostTagsTable temp = new WallPostTagsTable();
                temp.Tag = m;
                entity.PostTags.Add(temp);
            }

            foreach (var c in model.Comments)
            {
                entity.Comments.Add(ParseCommentModelToEntity(c));
            }

            return entity;
        }
Example #4
0
        public static WallModel ParseWallEntityToModel(Wall u)
        {
            var model = new WallModel();
            model.Id = u.Id;
            model.UserId = u.UserId;
            model.UserFirstName = u.User.FirstName;
            model.UserLastName = u.User.LastName;
            model.PosterId = u.PosterId;
            model.PosterFirstName = u.WhoPosted.FirstName;
            model.PosterLastName = u.WhoPosted.LastName;
            model.Message = u.Message;
            model.Picture = u.Picture;
            model.PostTime = u.PostTime;

            foreach (var m in u.PostTags)
            {
                WallPostTagsTable temp = new WallPostTagsTable();
                temp = m;
                model.PostTags.Add(temp.Tag);
            }

            foreach (var m in u.Comments)
            {
                model.Comments.Add(ParseCommentEntityToModel(m));
            }

            return model;
        }