public DomainModelResponse AddPost(PostAddRequest request)
        {
            EntityModel.Post parent = null;
            if(request.ParentPostTime != null && !string.IsNullOrWhiteSpace(request.ParentPostUserName))
            {
                parent = _repPost.Get(filter: f => f.TimePosted == request.ParentPostTime && f.UserName == request.ParentPostUserName).FirstOrDefault();
            }

            Group grp = _repGroup.Get(filter: f => f.GroupCode == request.GroupCode).FirstOrDefault();

            EntityModel.Post post = new EntityModel.Post()
            {
                UserName = request.UserName,
                TimePosted = request.TimePosted,
                PostText = request.PostText,
                Group = grp,
                GroupId = grp.GroupId,
                LastChangedTime = DateTime.UtcNow
            };
            if(parent!= null)
            {
                post.ParentId = parent.PostId;
            }
            else
            {
                post.ParentId = null;
            }

            _repPost.Add(post);
            _uow.Commit();
            _postResponse.addResponse("Add", MessageCodes.InfoCreatedSuccessfully, "Post");
            return _postResponse;
        }
 public async Task<bool> AddPost(PostAddRequest request)
 {
     try
     {
         HttpResponseMessage httpResp = apiCom.executePostAPI("Post", JsonConvert.SerializeObject(request));
         if (httpResp.IsSuccessStatusCode)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     catch
     {
         return false;
     }
 }
 public ActionResult NewPost(PostModel model)
 {
     if(ModelState.IsValid)
     {
         PostAddRequest par = new PostAddRequest()
         {
             PostText = model.PostText,
             TimePosted = DateTime.UtcNow,
             GroupCode = MvcApplication.currentGroupCode,
             UserName = MvcApplication.userName
         };
         bool result = _postCom.AddPost(par).Result;
         if(result)
         {
             return RedirectToAction("GroupDetail", "Group", routeValues: new { groupCode = MvcApplication.currentGroupCode });
         }
     }
     ModelState.AddModelError("", "Oops! Something wrong happened! Please try again.");
     return View(model);
 }