public ResponseDto ChangeMyPerson(PersonChangeMyPersonDto myPersonDto) { ResponseDto responseDto = new ResponseDto(); Session.MyPerson = PersonRelationController.GetMyPerson(myPersonDto, Session); responseDto.IsSuccess = true; return(responseDto); }
public static SessionMyPerson GetMyPerson(PersonChangeMyPersonDto myPersonDto, Session session) { // Getting my person // // Code below must return just one row. PersonRelationBusiness personRelationBusiness = new PersonRelationBusiness(); PersonRelationGetListCriteriaBo criteriaBo = new PersonRelationGetListCriteriaBo(); criteriaBo.PersonId = session.RealPerson.Id; criteriaBo.PersonRelationId = myPersonDto.PersonRelationId; criteriaBo.CurrencyId = myPersonDto.DefaultCurrencyId; criteriaBo.Session = session; PersonRelationListBo myPersonRelationBo = personRelationBusiness.GetList(criteriaBo).Bo[0]; SessionMyPerson myPerson = new SessionMyPerson(); myPerson.Id = myPersonDto.MyPersonId; myPerson.FullName = myPersonRelationBo.RelatedPersonFullName; myPerson.PersonTypeId = myPersonRelationBo.RelatedPersonTypeId; myPerson.RelationTypeId = myPersonRelationBo.RelationTypeId; myPerson.DefaultCurrencyId = myPersonRelationBo.RelatedPersonDefaultCurrencyId; myPerson.SelectedCurrencyId = myPerson.DefaultCurrencyId; return(myPerson); }
public ResponseDto <LoginReturnDto> Login(LoginDto loginDto) { DateTime loginTime = DateTime.Now; Guid tokenId = Guid.NewGuid(); string clientIpAddress = HttpContext.Current.Request.UserHostAddress; long?anonymousApiSessionId = null; if (Session != null && Session.RealPerson.Id == -2) { anonymousApiSessionId = Session.ApiSessionId; } LoginBo loginBo = new LoginBo() { Username = loginDto.Username, Password = loginDto.Password, LanguageId = loginDto.LanguageId, LoginTime = loginTime, TokenId = tokenId, ClientIpAddress = clientIpAddress, AnonymousApiSessionId = anonymousApiSessionId }; ResponseBo <SessionRealPerson> response = authBusiness.Login(loginBo); ResponseDto <LoginReturnDto> responseReturn = response.ToResponseDto <LoginReturnDto, SessionRealPerson>(); if (response.IsSuccess) { // We need to login first, then we will get my person data. Sessions.Session session = SessionManager.Login(response.Bo, loginTime, tokenId, clientIpAddress); PersonRelationBusiness personRelationBusiness = new PersonRelationBusiness(); session.RealPerson.MyPersonIdList = personRelationBusiness.GetMyPersonIdList(session.RealPerson.Id).Bo; PersonChangeMyPersonDto personChangeMyPersonDto = new PersonChangeMyPersonDto(); personChangeMyPersonDto.MyPersonId = response.Bo.Id; personChangeMyPersonDto.PersonRelationId = response.Bo.PersonRelationId; personChangeMyPersonDto.DefaultCurrencyId = response.Bo.DefaultCurrencyId; SessionMyPerson myPerson = PersonRelationController.GetMyPerson(personChangeMyPersonDto, session); session.MyPerson = myPerson; ////if user decides to change language in login screen, then we change it //if (loginDto.LanguageId != session.RealPerson.LanguageId) //{ // BaseBo baseBo = base.ToBaseBo(); // baseBo.Session.RealPerson.LanguageId = loginDto.LanguageId; // realPersonBusiness.ChangeLanguage(baseBo); //} responseReturn.Dto = new LoginReturnDto() { Id = response.Bo.Id, TokenId = session.TokenId, Name = response.Bo.Name, Surname = response.Bo.Surname, GenderId = response.Bo.GenderId, DefaultCurrencyId = response.Bo.DefaultCurrencyId }; } else { responseReturn.Dto = null; } // System.Threading.Thread.Sleep(5000); return(responseReturn); }