internal void Create(Stickynote pm) { string sql = @" INSERT INTO stickynotes (memberId, whiteboardId, creatorId) VALUES (@MemberId, @WhiteboardId, @CreatorId);"; _db.Execute(sql, pm); }
public async Task <ActionResult <string> > CreateAsync([FromBody] Stickynote pm) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); pm.CreatorId = userInfo.Id; return(Ok(_service.Create(pm))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
internal void Delete(int id, string userId) { Stickynote member = _repo.GetById(id); if (member == null) { throw new Exception("Invalid member"); } if (member.CreatorId != userId) { throw new Exception("Invalid User"); } _repo.Delete(id); }
internal string Create(Stickynote pm) { Whiteboard whiteboard = _whiteboardsrepo.GetById(pm.WhiteboardId); if (whiteboard == null) { throw new Exception("Not a valid whiteboard"); } if (whiteboard.CreatorId != pm.CreatorId) { throw new Exception("You are not the owner of this whiteboard"); } _repo.Create(pm); return("Created"); }