public IActionResult EditStudentNickname([FromRoute] int id, [FromBody] EditStudentNicknameRequest request)
        {
            if (!IsAuthorized())
            {
                return(Unauthorized());
            }

            try
            {
                var facade   = new StudentFacade();
                var response = facade.EditStudentNickname(id, request);

                switch (response.Status)
                {
                case HttpStatusCode.OK:
                    return(Ok(response));

                case HttpStatusCode.BadRequest:
                    return(BadRequest(BuildBadRequestMessage(response)));

                case HttpStatusCode.InternalServerError:
                    return(StatusCode(StatusCodes.Status500InternalServerError));

                case HttpStatusCode.NotFound:
                    return(NotFound());
                }
                s_logger.Fatal("This code should be unreachable, unknown result has occured.");
            }
            catch (Exception ex)
            {
                s_logger.Error(ex, "Unable to edit student's nickname.");
            }
            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
        public void EditStudentNickname()
        {
            AddStudentRequest request = new AddStudentRequest()
            {
                Nickname = AlphaNumericStringGenerator.GetString(10),
                SID      = AlphaNumericStringGenerator.GetStudentIDString()
            };

            StudentFacade      studentFacade = new StudentFacade();
            AddStudentResponse response      = studentFacade.AddStudentNickname(request);

            Assert.AreEqual(HttpStatusCode.OK, response.Status);

            EditStudentNicknameRequest editStudentNicknameRequest = new EditStudentNicknameRequest()
            {
                Nickname = AlphaNumericStringGenerator.GetString(10)
            };

            EditStudentNicknameResponse editStudentNicknameResponse = studentFacade.EditStudentNickname(response.StudentID, editStudentNicknameRequest);

            Assert.AreEqual(HttpStatusCode.OK, editStudentNicknameResponse.Status);
            Assert.IsTrue(editStudentNicknameResponse.Result);

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                var nickname = context.Nicknames.FirstOrDefault(n => n.StudentId == response.StudentID);

                Assert.AreEqual(editStudentNicknameRequest.Nickname, nickname.NickName);
            }
        }
        public void EditStudentNicknameNotFound()
        {
            StudentFacade studentFacade = new StudentFacade();

            EditStudentNicknameRequest editStudentNicknameRequest = new EditStudentNicknameRequest()
            {
                Nickname = AlphaNumericStringGenerator.GetString(10),
            };

            EditStudentNicknameResponse editStudentNicknameResponse = studentFacade.EditStudentNickname(-1, editStudentNicknameRequest);

            Assert.AreEqual(HttpStatusCode.NotFound, editStudentNicknameResponse.Status);
        }
        public void EditStudentNicknameExists()
        {
            AddStudentRequest request = new AddStudentRequest()
            {
                Nickname = AlphaNumericStringGenerator.GetString(10),
                SID      = AlphaNumericStringGenerator.GetStudentIDString()
            };

            StudentFacade      studentFacade = new StudentFacade();
            AddStudentResponse response      = studentFacade.AddStudentNickname(request);

            Assert.AreEqual(HttpStatusCode.OK, response.Status);

            EditStudentNicknameRequest editStudentNicknameRequest = new EditStudentNicknameRequest()
            {
                Nickname = request.Nickname
            };

            EditStudentNicknameResponse editStudentNicknameResponse = studentFacade.EditStudentNickname(response.StudentID, editStudentNicknameRequest);

            Assert.AreEqual(HttpStatusCode.BadRequest, editStudentNicknameResponse.Status);
        }