public void StartRegistration() { VtsWebServiceClient service = new VtsWebServiceClient(); service.RegisterUserCompleted += OnUserRegistered; service.RegisterUserAsync(UserAssembler.Disassemble(user)); }
public UserDTO Get(int UserID) { UserDTO oUserDTO = null; if (UserID > 0) { User oUser = oUsersRepo.GetUserByID(UserID); if (oUser != null) { oUserDTO = UserAssembler.ToDTO(oUser); /* * if (oUser.UserAddresses != null && oUser.UserAddresses.Count > 0) { * oUserDTO.UserAddresses = UserAddressAssembler.ToDTOs(oUser.UserAddresses); * } * * if (oUser.UserEmails != null && oUser.UserEmails.Count > 0) { * oUserDTO.UserEmails = UserEmailAssembler.ToDTOs(oUser.UserEmails); * } * * if (oUser.UserPhones != null && oUser.UserPhones.Count > 0) * { * oUserDTO.UserPhones = UserPhoneAssembler.ToDTOs(oUser.UserPhones); * } */ } } return(oUserDTO); }
public List <UserDTO> GetUsers() { List <UserDTO> oUserDTOs = new List <UserDTO>(); List <User> oUsers = oUsersRepo.GetUsers().ToList(); if (oUsers != null && oUsers.Count > 0) { oUserDTOs = UserAssembler.ToDTOs(oUsers); /* * if (oUser.UserAddresses != null && oUser.UserAddresses.Count > 0) * { * oUserDTO.UserAddresses = UserAddressAssembler.ToDTOs(oUser.UserAddresses); * } * * if (oUser.UserEmails != null && oUser.UserEmails.Count > 0) * { * oUserDTO.UserEmails = UserEmailAssembler.ToDTOs(oUser.UserEmails); * } * * if (oUser.UserPhones != null && oUser.UserPhones.Count > 0) * { * oUserDTO.UserPhones = UserPhoneAssembler.ToDTOs(oUser.UserPhones); * } */ } return(oUserDTOs); }
static StoredSettings() { TranslationManager.Instance.LanguageChanged += OnLanguageChanged; IVtsWebService client = Infrastructure.Container.GetInstance <IVtsWebService>(); try { if (client.CheckConnection() == "ok") { string login = AgentIsolatedStorageHelper.Login; string passwordHash = AgentIsolatedStorageHelper.PasswordHash; if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(passwordHash)) { return; } UserDto userDto = client.AuthenticateUser(login, passwordHash); if (userDto != null) { storedUser = UserAssembler.FromDtoToDomainObject(userDto); } else { Log.Warn("Could not log on with stored credentials!"); } TranslationManager.Instance.CurrentLanguageEnum = AgentIsolatedStorageHelper.Language; } } catch (Exception p) { Log.Error(p.Message); } }
private void GetClients() { try { Clients.Clear(); var service = Infrastructure.Container.GetInstance <IVtsWebService>(); if (LoggedUserContext.LoggedUser == null) { return; } foreach (UserDto userDto in service.GetClientsForPartner( LoggedUserContext.LoggedUser.Login, LoggedUserContext.LoggedUser.PasswordHash)) { User user = UserAssembler.FromDtoToDomainObject(userDto); clients.Add(new UserViewModel(user)); } } catch (Exception e) { const string msg = "Could not retrieve clients"; Log.Error(e, msg); ErrorWindow w = new ErrorWindow(e, msg); w.Owner = MainWindowKeeper.MainWindowInstance as Window; w.ShowDialog(); } }
public UserDTO Create(UserDTO modelDTO) { if (modelDTO != null) { User oUser = UserAssembler.ToEntity(modelDTO); return(UserAssembler.ToDTO(usersRepo.CreateUser(oUser))); } return(null); }
public void InsertUser(User userToADD) { var user = UserAssembler.ConvertUserToUserEntity(userToADD); Cql cqlQuery = new Cql("insert into users (id, first_name, last_name, gender, contacts) values (?, ?, ?, ?, ?)"); var preperadStatement = this.cassandraConnector.GetSession().Prepare(cqlQuery.Statement); var preparedQuery = preperadStatement.Bind(user.Id, user.FirstName, user.LastName, (int)user.Gender, user.ContactList); this.cassandraConnector.GetSession().Execute(preparedQuery); }
public IEnumerable <User> GetAllUsers() { Cql cqlQuery = new Cql("select * from users"); var result = this.cassandraConnector.GetSession().Execute(cqlQuery.Statement); var rows = result.GetRows().ToList(); return(rows != null ? UserAssembler.ConvertRowsToUser(rows) : Enumerable.Empty <User>()); }
public UserDTO Update(UserDTO modelDTO) { UserDTO returnUser = null; if (modelDTO != null && modelDTO.UserID > 0) { usersRepo.UpdateUser(UserAssembler.ToEntity(modelDTO)); returnUser = modelDTO; } return(returnUser); }
public List <UserDTO> Get() { List <UserDTO> userDTO = new List <UserDTO>(); List <User> oUsers = usersRepo.GetUsers().ToList(); if (oUsers != null && oUsers.Count > 0) { userDTO = UserAssembler.ToDTOs(oUsers); } return(userDTO); }
public User GetUserById(string id) { Cql cqlQuery = new Cql("select * from users where id = ?"); var preperadStatement = this.cassandraConnector.GetSession().Prepare(cqlQuery.Statement); var preparedQuery = preperadStatement.Bind(id); var result = this.cassandraConnector.GetSession().Execute(preparedQuery); var rows = result.GetRows().ToList().FirstOrDefault(); return(rows != null ? UserAssembler.ConvertRowToUser(rows) : null); }
public UserDTO Update(UserDTO oUserDTO) { UserDTO returnUser = null; if (oUserDTO != null && oUserDTO.UserID > 0) { oUsersRepo.UpdateUser(UserAssembler.ToEntity(oUserDTO)); returnUser = oUserDTO; } return(returnUser); }
public void GetForPartner(User user) { VtsWebServiceClient client = new VtsWebServiceClient(); client.GetClientsForPartnerCompleted += delegate(object s, GetClientsForPartnerCompletedEventArgs e) { if (e.Error != null) { errorCallback.Invoke(e.Error, e.Error.Message); } else { IList <User> result = new List <User>(); foreach (UserDto userDto in e.Result) { User gotUser = UserAssembler.Assemble(userDto); result.Add(gotUser); } usersCallback.Invoke(result); } }; client.GetAllUsersCompleted += delegate(object s, GetAllUsersCompletedEventArgs e) { if (e.Error != null) { errorCallback.Invoke(e.Error, e.Error.Message); } else { IList <User> result = new List <User>(); foreach (UserDto userDto in e.Result) { result.Add(UserAssembler.Assemble(userDto)); } usersCallback.Invoke(result); } }; if (user.Role == UserRole.Administrator) { client.GetAllUsersAsync(LoggedUserContext.LoggedUser.Login, LoggedUserContext.LoggedUser.PasswordHash); } else if (user.Role == UserRole.Partner) { client.GetClientsForPartnerAsync(user.Login, user.PasswordHash); client.CloseAsync(); } else { throw new Exception("Client has no access to this code."); } }
public UserDTO Get(int id) { UserDTO userDTO = null; if (id > 0) { User oUser = usersRepo.GetUserByID(id); if (oUser != null) { userDTO = UserAssembler.ToDTO(oUser); } } return(userDTO); }
/// <summary> /// Action uset lo log in a user after he has entered his credentials. /// </summary> public ActionResult Signin(string emailOrLogin, string password, string language) { string passwordHash = Sha256Hash.Calculate(password); UserDto user = service.AuthenticateUser(emailOrLogin, passwordHash); if (user == null) { TempData["LogonFailed"] = true; return(View("Logon")); } Session["User"] = UserAssembler.FromDtoToDomainObject(user); Session["Lang"] = LangConverter.Convert(language); return(RedirectToAction("Index", "Vehicles")); }
public CustomersController(IUnitOfWork unitOfWork, ICustomerRepository customerRepository, IUserRepository userRepository, IProjectRepository projectRepository, CustomerAssembler customerAssembler, UserAssembler userAssembler, ProjectAssembler projectAssembler) { _unitOfWork = unitOfWork; _customerRepository = customerRepository; _userRepository = userRepository; _projectRepository = projectRepository; _customerAssembler = customerAssembler; _userAssembler = userAssembler; _projectAssembler = projectAssembler; }
public void GetUser(string login, string password) { VtsWebServiceClient service = new VtsWebServiceClient(); service.AuthenticateUserCompleted += delegate(object s, AuthenticateUserCompletedEventArgs e) { if (e.Error != null) { ErrorCallback(e.Error, e.Error.Message); } else { User result = UserAssembler.Assemble(e.Result); GetUserCallback(result); } }; service.AuthenticateUserAsync(login, Sha256Hash.Calculate(password)); }
public ActionResult LogOn(LogOnModel model) { if (ModelState.IsValid) { VtsWebServiceClient service = new VtsWebServiceClient(); UserDto userDto = service.AuthenticateUser( model.Username, Sha256Hash.Calculate(model.Password)); if (userDto != null) { FormsAuthentication.SetAuthCookie(model.Username, false); SiteSession siteSession = new SiteSession(); siteSession.User = UserAssembler.FromDtoToDomainObject(userDto); Session["SiteSession"] = siteSession; return(RedirectToAction("Index", "AdminConsole")); } ModelState.AddModelError("", Resource.LogOnErrorMessage); return(View(model)); } return(View(model)); }
public HttpResponseMessage ReadAll() { // CAD, CEN, EN, returnValue UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; List <UserEN> userEN = null; List <UserDTOA> returnValue = null; try { SessionInitializeWithoutTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Data // TODO: paginación userEN = userCEN.ReadAll(0, -1).ToList(); // Convert return if (userEN != null) { returnValue = new List <UserDTOA>(); foreach (UserEN entry in userEN) { returnValue.Add(UserAssembler.Convert(entry, session)); } } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 204 - Empty if (returnValue == null || returnValue.Count == 0) { return(this.Request.CreateResponse(HttpStatusCode.NoContent)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }
public HttpResponseMessage New_([FromBody] UserDTO dto) { // CAD, CEN, returnValue, returnOID UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserDTOA returnValue = null; int returnOID = -1; // HTTP response HttpResponseMessage response = null; string uri = null; try { SessionInitializeTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Create returnOID = userCEN.New_( dto.Surnames //Atributo Primitivo: p_surnames , dto.IsActive //Atributo Primitivo: p_isActive , dto.IsDiseased //Atributo Primitivo: p_isDiseased , dto.Pass //Atributo Primitivo: p_pass , dto.Name //Atributo Primitivo: p_name , dto.Description //Atributo Primitivo: p_description , dto.Email //Atributo Primitivo: p_email ); SessionCommit(); // Convert return returnValue = UserAssembler.Convert(userRESTCAD.ReadOIDDefault(returnOID), session); } catch (Exception e) { SessionRollBack(); if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 201 - Created response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue); // Location Header /* * Dictionary<string, object> routeValues = new Dictionary<string, object>(); * * // TODO: y rolPaths * routeValues.Add("id", returnOID); * * uri = Url.Link("GetOIDUser", routeValues); * response.Headers.Location = new Uri(uri); */ return(response); }
public HttpResponseMessage ReadOID(int idUser) { // CAD, CEN, EN, returnValue UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserEN userEN = null; UserDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Data userEN = userCEN.ReadOID(idUser); // Convert return if (userEN != null) { returnValue = UserAssembler.Convert(userEN, session); } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }
private void GoForward() { if (IsRegister) { User user = new User(); user.Login = Username; user.PasswordHash = Sha256Hash.Calculate(PasswordText); user.Role = UserRole.Partner; user.RegisteredDate = DateTime.Now; user.Email = Email; user.Name = "???"; user.Phone = "???"; user.Profile = null; user.Surname = "???"; UserDto userDto = UserAssembler.FromDomainObjectToDto(user); IVtsWebService service = Infrastructure.Container.GetInstance <IVtsWebService>(); try { service.RegisterUser(userDto); UserDto userDtoNew = service.AuthenticateUser(Username, Sha256Hash.Calculate(PasswordText)); User userNew = UserAssembler.FromDtoToDomainObject(userDtoNew); LoggedUserContext.LoggedUser = userNew; StoredSettings.Current = userNew; } catch (Exception e) { Log.Error(e, e.Message); ErrorWindow wnd = new ErrorWindow(e.Message); wnd.Owner = MainWindowKeeper.MainWindowInstance as Window; wnd.ShowDialog(); } } else if (IsLogon) { VtsWebServiceClient service = new VtsWebServiceClient(); try { UserDto userDto = service.AuthenticateUser(Username, Sha256Hash.Calculate(PasswordText)); if (userDto != null) { User user = UserAssembler.FromDtoToDomainObject(userDto); LoggedUserContext.LoggedUser = user; StoredSettings.Current = user; } else { ShowIncorrectCredentialsText(); } } catch (Exception e) { Log.Error(e, e.Message); ErrorWindow wnd = new ErrorWindow(e.Message); wnd.Owner = MainWindowKeeper.MainWindowInstance as Window; wnd.ShowDialog(); } } }
public List <UserDTO> GetUsersBySearch(string searchText, int from, int to) { return(UserAssembler.ToDTOs(usersRepo.GetUsersBySearch(searchText, from, to))); }