public IHttpActionResult CreateNewUser(User user)
 {
     try
     {
         this.RegisterWrapper.CreateNewUser(user);
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = string.Format("{0}, {1}", mex.Message, mex.StackTrace)
         }));
     }
     catch (WrapperException wex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = string.Format("{0}, {1}", wex.InnerException.Message, wex.InnerException.StackTrace)
         }));
     }
     catch (System.Exception)
     {
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error creating new user", ERROR_REGISTER_USER);
     }
 }
 public IHttpActionResult ValidateNewUser([FromBody] string token)
 {
     try
     {
         // Subscript user
         this.RegisterWrapper.ValidateUser(token);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception)
     {
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error validation new user", ERROR_VALIDATE_USER);
     }
 }
 public IHttpActionResult ResetPassword(ResetPasswordPrm resetPasswordPrm)
 {
     try
     {
         // Subscript user
         this.RegisterWrapper.ResetPassword(resetPasswordPrm.Token, resetPasswordPrm.Password);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception)
     {
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error on password reset", ERROR_RESET_PASSWORD);
     }
 }
Example #4
0
        public async Task <IHttpActionResult> UploadProfilePicture()
        {
            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }
            // Define the stream provider
            MultipartMemoryStreamProvider memoryStreamProvider = new MultipartMemoryStreamProvider();

            try
            {
                Guid userDataId = this.GetUserDataId();
                // Read the form data.
                await Request.Content.ReadAsMultipartAsync(memoryStreamProvider).ContinueWith(async(task) => {
                    // Get Http Content
                    HttpContent content = memoryStreamProvider.Contents[0];
                    // Get the stream
                    Stream stream = await content.ReadAsStreamAsync();
                    // Save the file
                    this.UserWrapper.UploadProfilePicture(userDataId, stream);
                });

                // Return the response
                return(Ok(new GeneralResponse()
                {
                    Error = false, Message = ""
                }));
            }
            catch (ManagerException mex)
            {
                // Save entry in log
                this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
                // Throw the exception
                return(Ok(new GeneralResponse()
                {
                    Error = true, Message = mex.Message
                }));
            }
            catch (WrapperException wex)
            {
                // Save entry in log
                this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
                // Throw the exception
                return(Ok(new GeneralResponse()
                {
                    Error = true, Message = wex.Message
                }));
            }
            catch (System.Exception ex)
            {
                // Save entry in log
                this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
                // Throw the exception
                throw ExceptionResponse.ThrowException("Error uploading profile picture", ERROR_UPLOADING_PROFILE_PICTURE);
            }
        }
 public IEnumerable <Invitation> GetCurrent()
 {
     try
     {
         return(this.IInvitationMgr.GetByEmail(this.GetUserDataEmail()));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting invitations", ERROR_IN_GET_INVITATION);
     }
 }
 public IEnumerable <Event> GetCurrent()
 {
     try
     {
         return(this.IEventMgr.GetByUser(this.GetUserDataId()));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting Event", ERROR_IN_GET_EVENT);
     }
 }
Example #7
0
 public Transport GetById(Guid transportId)
 {
     try
     {
         return(this.ITransportMgr.GetById(transportId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting transport", ERROR_IN_GET_TRANSPORT);
     }
 }
 public IEnumerable <Passenger> GetByEventGroupId(Guid transportId)
 {
     try
     {
         return(this.IPassengerMgr.GetByTransportId(transportId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting Passenger", ERROR_IN_GET_PASSENGER);
     }
 }
Example #9
0
 public IEnumerable <Transport> GetByEventId(Guid eventId, bool travelSense)
 {
     try
     {
         return(this.ITransportMgr.GetByEventId(eventId, travelSense));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting transport", ERROR_IN_GET_TRANSPORT);
     }
 }
 public Passenger GetByUserIdEventIdSense(Guid userId, Guid eventId, bool travelSense)
 {
     try
     {
         return(this.IPassengerMgr.GetByUserIdEventIdSense(userId, eventId, travelSense));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting Passenger", ERROR_IN_GET_PASSENGER);
     }
 }
 public IEnumerable <Assistant> GetByEventId(Guid eventId)
 {
     try
     {
         return(this.IAssistantMgr.GetByEventId(eventId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting Assistant", ERROR_IN_GET_ASSISTANT);
     }
 }
Example #12
0
 public EventGroup GetById(Guid eventGroupId)
 {
     try
     {
         return(this.IEventGroupMgr.GetById(eventGroupId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting EventGroup", ERROR_IN_GET_EVENT_GROUP);
     }
 }
Example #13
0
 public User GetCurrentUser()
 {
     try
     {
         return(this.IUserMgr.GetById(this.GetUserDataId()));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register("CRM Server", this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting current user", ERROR_IN_GET_CURRENT_USER);
     }
 }
Example #14
0
 public IEnumerable <MenuItemView> GetUserMenu()
 {
     try
     {
         return(this.MenuItemWrapper.GetUserMenu(this.GetUserDataEmail()));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register("Auth Server", this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting MenuItem", ERROR_IN_GET);
     }
 }
Example #15
0
 public IEnumerable <UserDepartment> GetByIds(Guid userId, Guid eventId)
 {
     try
     {
         return(this.IUserDepartmentMgr.GetByUserIdEventId(userId, eventId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting User Department", ERROR_IN_GET_USERDEPARTMENT);
     }
 }
 public Address GetById(Guid eventId)
 {
     try
     {
         return(this.IAddressMgr.GetByEventId(eventId));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error getting Address", ERROR_IN_GET_ADDRESS);
     }
 }
Example #17
0
 public IHttpActionResult Update(User user)
 {
     try
     {
         // Assign id
         user.UserId = this.GetUserDataId();
         // Update user
         this.IUserMgr.Update(user);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error updating user", ERROR_UPDATING_USER);
     }
 }
 public IHttpActionResult Accept([FromUri] Guid invitationId)
 {
     try
     {
         // Update user
         this.InvitationWrapper.Accept(invitationId, this.GetUserDataId());
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error accepting invitation", ERROR_ACCEPTING_INVITATION);
     }
 }
Example #19
0
 public IHttpActionResult UpdatePassword([FromBody] string password)
 {
     try
     {
         // Update password
         this.UserWrapper.ChangePassword(this.GetUserDataId(), password);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error updating user password", ERROR_UPDATING_USER_PASSWORD);
     }
 }
Example #20
0
 public IHttpActionResult DownloadProfilePicture()
 {
     try
     {
         // User data id
         Guid userDataId = this.GetUserDataId();
         // Return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = this.UserWrapper.DownloadProfilePhoto(userDataId)
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error downloading profile picture", ERROR_DOWNLOADING_PROFILE_PICTURE);
     }
 }
 public IHttpActionResult Import(InvitationImportPrm invitationImportPrm)
 {
     try
     {
         // Update user
         this.InvitationWrapper.Import(invitationImportPrm.CollectionEmail, invitationImportPrm.EventId);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error accepting invitation", ERROR_REJECTING_INVITATION);
     }
 }
Example #22
0
 public IHttpActionResult Save(Car car)
 {
     try
     {
         car.UserId = this.GetUserDataId();
         this.ICarMgr.Save(car);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error creating car", ERROR_CREATING_CAR);
     }
 }
 public IHttpActionResult Update(Assistant assistant)
 {
     try
     {
         this.AssistantWrapper.UpdateOwner(assistant);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error updating assistant", ERROR_UPDATING_ASSISTANT);
     }
 }
 public IHttpActionResult Create(Passenger passenger)
 {
     try
     {
         this.PassengerWrapper.Create(passenger, this.GetUserDataEmail(), this.GetUsername(), this.GetLastname());
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error creating passenger", ERROR_CREATING_PASSENGER);
     }
 }
Example #25
0
 public IHttpActionResult Create(Transport transport)
 {
     try
     {
         this.TransportWrapper.Create(transport, this.GetUserDataId());
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error creating transport", ERROR_CREATING_TRANSPORT);
     }
 }
Example #26
0
 public IHttpActionResult Deactivate([FromBody] Guid carId)
 {
     try
     {
         this.CarWrapper.Deactivate(carId, this.GetUserDataId());
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error deactivating car", ERROR_DEACTIVATING_CAR);
     }
 }
Example #27
0
 public IHttpActionResult Create(UserDepartmentCreatePrm userDepartmentCreatePrm)
 {
     try
     {
         this.UserDepartmentWrapper.Create(userDepartmentCreatePrm);
         // return the response
         return(Ok(new GeneralResponse()
         {
             Error = false, Message = ""
         }));
     }
     catch (ManagerException mex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, mex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = mex.Message
         }));
     }
     catch (WrapperException wex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_WARNING, wex);
         // Throw the exception
         return(Ok(new GeneralResponse()
         {
             Error = true, Message = wex.Message
         }));
     }
     catch (System.Exception ex)
     {
         // Save entry in log
         this.SystemLogWrapper.Register(SERVER, this.GetUserDataId(), SystemLogWrapper.TYPE_ERROR, ex);
         // Throw the exception
         throw ExceptionResponse.ThrowException("Error creating user department", ERROR_CREATING_USER_DEPARTMENT);
     }
 }