示例#1
0
        public HttpResponseMessage PutFormAddStudent(int id, string studentId)
        {
            string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value;

            logger.Info("UserId: " + userId + ": Requesting Form Update For Form Id: " + id + ", add Student Id: " + studentId);

            try
            {
                Form saved = formsService.AddStudent(id, studentId);

                if (saved == null)
                {
                    logger.Info("Failed!");
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Failed!"));
                }

                logger.Info("Success!");
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                logger.Error(e);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }