コード例 #1
0
        public HttpResponseMessage Post(UserRegistrationDTO user)
        {
            UsersModel userModel = new UsersModel();
            bool add = userModel.AddUser(user);
            HttpResponseMessage response;

            if (add)
            {
                SuccessMessage msg = new SuccessMessage("Registration successful!");

                response = Request.CreateResponse(HttpStatusCode.OK, msg);
                return response;

            }
            else
            {
                ErrorMessage msg = new ErrorMessage("Registration failed! Username or email already exists");

                response = Request.CreateResponse(HttpStatusCode.Forbidden, msg);
                return response;

            }
        }
コード例 #2
0
ファイル: UserLogic.cs プロジェクト: GeorgeMi/PollApp
 public void AddUser(UserRegistrationDTO userDTO)
 {
     //adauga un user
     User user = new User() { Username = userDTO.Username, Password = userDTO.Password, Email = userDTO.Email, Role = "user" };
     _dataAccess.UserRepository.Add(user);
 }