Beispiel #1
0
        public async Task <IHttpActionResult> PostUser(HikerModel user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            String relativePath = null;

            if (user.Photo != null)
            {
                relativePath = "~/Images/Users/Profile Pictures/" + user.IdCard + ".jpg";
            }
            ObjectParameter output = new ObjectParameter("responseMessage", typeof(string));

            db.PR_CreateHiker(user.IdCard, user.Username, user.Password, user.FirstName, user.MiddleName, user.LastName,
                              user.SecondLastName, user.Gender, user.BirthDate, user.Nationality, relativePath, user.AccountNumber, output);
            JsonResponse response = new JsonResponse()
            {
                Response = output.Value.ToString()
            };

            if (response.Response == "Success" && relativePath != null)
            {
                savePhoto(user.Photo, relativePath);
            }
            return(Ok(response));
        }