internal void Create(Stickynote pm)
        {
            string sql = @"
        INSERT INTO stickynotes
        (memberId, whiteboardId, creatorId)
        VALUES
        (@MemberId, @WhiteboardId, @CreatorId);";

            _db.Execute(sql, pm);
        }
示例#2
0
        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));
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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");
        }