예제 #1
0
        public HttpResponseMessage GetFormByAttendingTeacherUserName([FromUri] string teacherUserName)
        {
            string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value;

            logger.Info("UserId: " + userId + ": Requesting Form by attending teacher's user name: " + teacherUserName);

            try
            {
                FormDTOForAdmin form = formsService.GetFormByAttendingTeacherLastName(teacherUserName);

                if (form == null)
                {
                    logger.Info("The Form by attending teacher's last name: " + teacherUserName + " was not found.");
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "The Form by attending teacher's last name: " + teacherUserName + " was not found."));
                }

                logger.Info("Success! Form by id: " + form.Id);
                return(Request.CreateResponse(HttpStatusCode.OK, form));
            }
            catch (Exception e)
            {
                logger.Error(e);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }