public IHttpActionResult PostComment(Guid appId, CommentReview review)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             if (review != null)
             {
                 if (review.Id > 0)
                 {
                     var post = entity.Posts.FirstOrDefault(x => x.Id == review.Id);
                     post.Txt        = review.Comment;
                     post.CreateTime = DateTime.UtcNow;
                     if (post != null && review.Review != null)
                     {
                         entity.SaveChanges();
                         var comment = entity.Comments.FirstOrDefault(x => x.PostId == post.Id);
                         comment.Msg        = review.Review;
                         comment.UserName   = review.ReviewUsername;
                         comment.CreateTime = DateTime.UtcNow;
                     }
                 }
                 else
                 {
                     var post = entity.Posts.Add(new Post()
                     {
                         AppId      = appId,
                         CreateTime = DateTime.UtcNow,
                         Txt        = review.Comment,
                         UserName   = review.Username
                     });
                     entity.SaveChanges();
                     if (post != null)
                     {
                         entity.Comments.Add(new Comment()
                         {
                             CreateTime = DateTime.UtcNow,
                             PostId     = post.Id,
                             Msg        = review.Review,
                             UserName   = null
                         });
                     }
                 }
             }
             entity.SaveChanges();
             return(Ok());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult PutDownloadCountMaster(Guid appId)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var appMaster = entity.AppMasters.FirstOrDefault(x => x.Id == appId);
             if (appMaster != null)
             {
                 if (appMaster.Download == null)
                 {
                     appMaster.Download = 1;
                 }
                 else
                 {
                     appMaster.Download += 1;
                 }
             }
             entity.SaveChanges();
             return(Ok(appMaster));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult PostCategory(Category category)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             entity.Categories.Add(category);
             entity.SaveChanges();
             return(Ok(category));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult DeleteDocuments(Guid id)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var app = entity.DocumentMasters.FirstOrDefault(x => x.Id == id);
             app.IsDeleted   = true;
             app.DeletedTime = DateTime.Now;
             entity.SaveChanges();
             return(Ok("web page app deleted successfully"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult DeleteAppMaster(AppMaster master)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var app = entity.AppMasters.FirstOrDefault(x => x.Id == master.Id);
             app.IsDeleted   = true;
             app.DeletedTime = DateTime.Now;
             entity.SaveChanges();
             return(Ok("hosted app updated successfully"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#6
0
 public IHttpActionResult DeleteThirdPartyApp(Guid id)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var app = entity.ThirdParties.FirstOrDefault(x => x.Id == id);
             app.IsDeleted   = true;
             app.DeletedTime = DateTime.Now;
             entity.SaveChanges();
             return(Ok("third party app changed successfully"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult PutDocuments(DocumentMaster master)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var app = entity.DocumentMasters.FirstOrDefault(x => x.Id == master.Id);
             app.Description = master.Description;
             app.Documents   = master.Documents;
             app.Title       = master.Title;
             entity.SaveChanges();
             return(Ok("web page app changed successfully"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public IHttpActionResult PostDocuments()
        {
            try
            {
                using (MususAppEntities entity = new MususAppEntities())
                {
                    var            httpRequest = HttpContext.Current.Request;
                    DocumentMaster master      = null;
                    if (httpRequest.Params["id"] != null)
                    {
                        var id = Guid.Parse(httpRequest.Params["id"]);
                        master = entity.DocumentMasters.FirstOrDefault(
                            x => x.Id == id);
                        if (master != null)
                        {
                            UploadAttachments(master);
                        }
                        else
                        {
                            BadRequest("Document not found");
                        }
                    }

                    else
                    {
                        master             = new DocumentMaster();
                        master.Id          = Guid.NewGuid();
                        master.DeletedTime = null;
                        master.IsDeleted   = false;
                        master.CreatedTime = DateTime.UtcNow;
                        UploadAttachments(master);
                        entity.DocumentMasters.Add(master);
                    }

                    entity.SaveChanges();
                    return(Ok(master));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public IHttpActionResult Put(int rating, Guid appId)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             entity.Ratings.Add(new Rating()
             {
                 AppId    = appId,
                 Point    = rating,
                 Username = RequestContext.Principal.Identity.Name
             });
             entity.SaveChanges();
             return(Ok());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#10
0
 public IHttpActionResult PostThirdPartyApp()
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var        httpRequest = HttpContext.Current.Request;
             ThirdParty master      = null;
             if (httpRequest.Params["id"] != null)
             {
                 var id = Guid.Parse(httpRequest.Params["id"]);
                 master = entity.ThirdParties.FirstOrDefault(x => x.Id == id);
                 if (master != null)
                 {
                     UploadAttachments(master);
                 }
                 else
                 {
                     return(BadRequest("Thirdparty app does not exists"));
                 }
             }
             else
             {
                 master             = new ThirdParty();
                 master.CreatedTime = DateTime.UtcNow;
                 master.IsDeleted   = false;
                 master.DeletedTime = null;
                 master.Id          = Guid.NewGuid();
                 UploadAttachments(master);
                 entity.ThirdParties.Add(master);
             }
             entity.SaveChanges();
             return(Ok(master));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#11
0
 public IHttpActionResult DeleteCategory(int id)
 {
     try
     {
         using (MususAppEntities entity = new MususAppEntities())
         {
             var cat = entity.Categories.FirstOrDefault(x => x.Id == id);
             if (cat == null)
             {
                 return(BadRequest());
             }
             else
             {
                 entity.Categories.Remove(cat);
                 entity.SaveChanges();
                 return(Ok());
             }
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }