public ActionResult <Project> PutProject(int id, Project project) { if (id != project.ProjectId) { return(BadRequest()); } _context.Entry(project).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult PutUsergroups(Usergroups usergroups) { Usergroups group = _context.Usergroups.Find(usergroups.GroupId, usergroups.ProjectId); group.Name = usergroups.Name; group.Introduction = usergroups.Introduction; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsergroupsExists(usergroups.GroupId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult PutUsers(string account, UserPut userput) { ALiYunOss.PutImageIntoPath(userput.icon, account); Users user = _context.Users.Find(account); user.Icon = account; user.Name = userput.name; user.Nickname = userput.nickname; user.PhoneNum = userput.phoneNum; user.EmailAddress = userput.emailAddress; user.Sex = userput.sex; user.School = userput.school; user.College = userput.college; user.Grade = userput.grade; user.StudentNumber = userput.studentNumber; user.Intro = userput.intro; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(account)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult <MomentStar> PostMomentStar(MomentStar momentStar) { _context.MomentStar.Add(momentStar); try{ _context.SaveChanges(); } catch (DbUpdateException) { if (MomentStarExists(momentStar)) { return(Conflict()); } else if (!MomentExists(momentStar.MomentId)) { return(BadRequest()); } else if (!FavouritePackageExists(momentStar.Account, momentStar.Name)) { return(BadRequest()); } else { throw; } } return(CreatedAtAction("GetMomentStar", new { id = momentStar.MomentId }, momentStar)); }
public IActionResult PutReport(int id, Report report) { if (id != report.ReportId) { return(BadRequest()); } if (report.DealStatus != "successful" && report.DealStatus != "failed") { return(BadRequest()); } _context.Entry(report).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReportExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult <Comment> PostComment(Comment comment) { _context.Comment.Add(comment); try { _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetComment", new { id = comment.CommentId }, comment)); }
public ActionResult <Reply> PostReply(Reply reply) { _context.Reply.Add(reply); try { _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetReply", new { id = reply.ReplyId }, reply)); }
public ActionResult <Moment> PostMoment(Moment moment) { _context.Moment.Add(moment); try { _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetMoment", new { id = moment.MomentId }, moment)); }
public ActionResult <Post> PostPost(GroupPost groupPost) { Usergroups usergroups = new Usergroups (groupPost.projectId, groupPost.leaderAccount, groupPost.name, groupPost.content); _context.Usergroups.Add(usergroups); _context.SaveChanges(); Post post = new Post (groupPost.projectId, usergroups.GroupId, groupPost.postTime, groupPost.content, groupPost.maxMenberNum); _context.Post.Add(post); _context.SaveChanges(); return(CreatedAtAction("GetPost", new { id = post.PostId }, post)); }
public ActionResult <Subscribe> PostSubscribe(Subscribe subscribe) { _context.Subscribe.Add(subscribe); try { _context.SaveChanges(); } catch (DbUpdateException) { if (SubscribeExists(subscribe)) { return(Conflict()); } else if (!UserExists(subscribe.Account)) { return(BadRequest()); } else if (!ProjectExists(subscribe.ProjectId)) { return(BadRequest()); } else { throw; } } return(CreatedAtAction("GetSubscribe", new { id = subscribe.ProjectId }, subscribe)); }
public ActionResult <PostStar> PostPostStar(PostStar postStar) { _context.PostStar.Add(postStar); try { _context.SaveChanges(); } catch (DbUpdateException) { if (PostStarExists(postStar)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetPostStar", new { id = postStar.ProjectId }, postStar)); }
public ActionResult <Message> PostMessage(Message message) { _context.Message.Add(message); try{ _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetMessage", new { id = message.MessageId }, message)); }
public ActionResult <Notice> PostNotice(Notice notice) { _context.Notice.Add(notice); try { _context.SaveChanges(); } catch (DbUpdateException) { throw; } return(CreatedAtAction("GetNotice", new { id = notice.NoticeId }, notice)); }
public IActionResult PutApplication(ApplicationPut applicationPut) { int projectid = applicationPut.projectId; int groupid = applicationPut.groupId; var application = _context.Application.Find(projectid, groupid, applicationPut.account); if (applicationPut.result == "successful") { var group = _context.Usergroups.Find(groupid, projectid); Member new_member = new Member { ProjectId = projectid, GroupId = groupid, Account = applicationPut.account }; //var new_member = _context.Users.Find(account); _context.Member.Add(new_member); application.Status = "successful"; } else { application.Status = "failed"; } try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ApplicationExists(projectid, groupid, applicationPut.account)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult PutDiscussion(Discussion discussion) { _context.Entry(discussion).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DiscussionExists(discussion.DiscussionId, discussion.ProjectId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult <Member> DeleteMember(int projectid, int groupid, string account) { var member = _context.Member.Find(projectid, groupid); if (member == null) { return(NotFound()); } _context.Member.Remove(member); _context.SaveChanges(); return(member); }
public IActionResult PutFavouritePackage(FavouritePackage editFavPackage) { if (editFavPackage.Privacy != "public" && editFavPackage.Privacy != "private") { return(BadRequest()); } FavouritePackage fav = _context.FavouritePackage.Find(editFavPackage.Account, editFavPackage.Name); if (fav == null) { return(NotFound()); } fav.Privacy = editFavPackage.Privacy; try{ _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); }
public ActionResult <Notification> PostNotification(Notification notification) { _context.Notification.Add(notification); _context.SaveChanges(); return(CreatedAtAction("GetNotification", new { id = notification.NotifiId }, notification)); }