public override ProfileResponse Profile(Agent agent, ProfileRequest profileRequest) { ProfileResponse agentProfile; var agentProfileKeyFormatted = string.Format(CacheKeys.AGENTPROFILEKEY, agent.AgentId, agent.AgentSequence); var cachedResult = _cacheManager.Contains <CachedObjectResponseContainer <ProfileResponse> >(agentProfileKeyFormatted, CacheRegion.Global); Func <ProfileResponse> profileCacheSaveFunction = delegate() { Console.WriteLine("Entered profileCacheSaveFunction"); agentProfile = base.Profile(agent, profileRequest); var CachedContainer = CacheAheadHelper.PopulateCacheMetadata <ProfileResponse>(agentProfile, CachePolicies.FullWeek); _cacheManager.Save(agentProfileKeyFormatted, CachedContainer, CacheRegion.Global, CachePolicies.FullWeek); return(agentProfile); }; if (cachedResult.Exists) { CacheAheadHelper.ExecuteCacheAheadProcess <ProfileResponse>(profileCacheSaveFunction, cachedResult.CachedObj.CacheMetadata); agentProfile = cachedResult.CachedObj.DataObject; } else { agentProfile = profileCacheSaveFunction(); } return(agentProfile); }
public ProfileResponse Profile(ProfileRequest req) { var agent = _agents.GetAgent(req.AgentID, req.AgentSequence); _agentConnectConfig.DecorateRequest(req); return(_testRunner.AgentConnect.Profile(agent, req)); }
public async Task <IActionResult> ProfilePicture([FromForm] ProfileRequest request) { JsonResponse <string> objResult = new JsonResponse <string>(); try { string uploadsFolder = Path.Combine(this._env.WebRootPath, "images"); string imageName = await this._settingService.UploadedFile(request.file, uploadsFolder); bool success = await this._settingService.SaveProfilePicture(request.userId, imageName); if (success) { objResult.Data = "Success"; objResult.Status = StaticResource.SuccessStatusCode; objResult.Message = StaticResource.SuccessMessage; return(new OkObjectResult(objResult)); } } catch (Exception ex) { HttpContext.RiseError(ex); objResult.Data = ex.Message; objResult.Status = StaticResource.FailStatusCode; objResult.Message = StaticResource.FailMessage; } return(new OkObjectResult(objResult)); }
public async Task CalculateProfileService_ShouldCorrectlyProfileEdgeCaseAllocationJustWithinPatternMonths() { // arrange FundingStreamPeriodProfilePattern pattern = TestResource.FromJson <FundingStreamPeriodProfilePattern>( NamespaceResourcesResideIn, "Resources.PESPORTSPREM.json"); // first period rouonds down ProfileRequest peSportsPremReq1 = new ProfileRequest( fundingStreamId: "PSG", fundingPeriodId: "AY-1819", fundingLineCode: "FL1", fundingValue: 1000); IProfilePatternRepository mockProfilePatternRepository = Substitute.For <IProfilePatternRepository>(); mockProfilePatternRepository .GetProfilePattern(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()) .Returns(pattern); ICalculateProfileService calculateProfileService = GetCalculateProfileServiceWithMockedDependencies(mockProfilePatternRepository); // act IActionResult responseResult = await calculateProfileService.ProcessProfileAllocationRequest(peSportsPremReq1); // assert responseResult .Should().BeOfType <OkObjectResult>(); OkObjectResult responseAsOkObjectResult = responseResult as OkObjectResult; AllocationProfileResponse response = responseAsOkObjectResult.Value as AllocationProfileResponse; response.DeliveryProfilePeriods.ToArray().FirstOrDefault(q => q.TypeValue == "October").ProfileValue.Should().Be(583.00M); response.DeliveryProfilePeriods.ToArray().FirstOrDefault(q => q.TypeValue == "April").ProfileValue.Should().Be(417.00M); response.DeliveryProfilePeriods.Length.Should().Be(3); }
public void Request_ParseFailure() { Assert.Throws <ArgumentNullException>(() => ProfileRequest.Parse(null)); Assert.Throws <ArgumentNullException>(() => ProfileRequest.Parse(string.Empty)); Assert.Throws <FormatException>(() => ProfileRequest.Parse("TEST")); Assert.Throws <FormatException>(() => ProfileRequest.Parse("TEST: arg")); }
public async Task CalculateProfileService_ShouldCorrectlyProfileFullLengthAllocationWithRoundUp() { // arrange FundingStreamPeriodProfilePattern pattern = TestResource.FromJson <FundingStreamPeriodProfilePattern>( NamespaceResourcesResideIn, "Resources.DSG.json"); // first period rouonds down ProfileRequest peSportsPremReq1 = new ProfileRequest( fundingStreamId: "DSG", fundingPeriodId: "FY-2021", fundingLineCode: "DSG-002", fundingValue: 10000543); IProfilePatternRepository mockProfilePatternRepository = Substitute.For <IProfilePatternRepository>(); mockProfilePatternRepository .GetProfilePattern(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()) .Returns(pattern); ICalculateProfileService calculateProfileService = GetCalculateProfileServiceWithMockedDependencies(mockProfilePatternRepository); // act IActionResult responseResult = await calculateProfileService.ProcessProfileAllocationRequest(peSportsPremReq1); // assert responseResult .Should().BeOfType <OkObjectResult>(); OkObjectResult responseAsOkObjectResult = responseResult as OkObjectResult; AllocationProfileResponse response = responseAsOkObjectResult.Value as AllocationProfileResponse; response.DeliveryProfilePeriods.ToArray().FirstOrDefault(q => q.TypeValue == "April").ProfileValue.Should().Be(400021M); response.DeliveryProfilePeriods.ToArray().LastOrDefault(q => q.TypeValue == "March").ProfileValue.Should().Be(400039M); response.DeliveryProfilePeriods.Length.Should().Be(25); }
private static void Main() { var city = SelectCity(); var storage = new NativeStorageProvider(); var authToken = storage.AuthToken; if (string.IsNullOrEmpty(authToken)) { var credentialsProvider = new ConsoleCredentialsProvider(); var loginRequest = new LoginRequest(credentialsProvider.Login, credentialsProvider.Password); var response = ImaxApi.Login(loginRequest).Result; if (response.Succeeded) { authToken = storage.AuthToken = response.Token; } else { return; } } var profileRequest = new ProfileRequest(authToken); var profileResponse = ImaxApi.Profile(profileRequest).Result; var registerRequest = new RegisterRequest(new CustomerName("Vasya", null, "Pupkin"), Gender.Male, new DateTime(2012, 12, 21), PhoneNumber.Parse("+380123456789"), "*****@*****.**", "qwerty"); var registerResponse = ImaxApi.Register(registerRequest).Result; }
public ContentResult UpdateProfile(FormCollection form) { JObject json = new JObject(); json["error"] = false; json["message"] = ""; if (this.IsLoggedIn()) { if (this.GetAccount().Type != AccountType.Applicant && ((Employee)this.GetAccount().Profile).Department.Type == DepartmentType.HumanResources) { if (form.GetValue("id") != null) { try { ProfileRequest pr = new ProfileRequest(Int32.Parse(form.GetValue("id").AttemptedValue), true); int temp = pr.NewProfile.ProfileID; pr.NewProfile.ProfileID = pr.CurrentProfile.ProfileID; pr.NewProfile.Update(false); Account ac = this.GetAccount(); ac.Profile.Profile = pr.NewProfile; Session["user"] = ac; pr.NewProfile.ProfileID = temp; pr.NewProfile.Delete(); pr.Delete(); json["message"] = "Successfuly approved profile request..."; } catch (Exception e) { json["error"] = true; json["message"] = e.Message; } } else { json["error"] = true; json["message"] = "Form is incomplete"; } } else { json["error"] = true; json["message"] = "You are not authorized to continue"; } } else { json["error"] = true; json["message"] = "You must be logged in to continue"; } return(Content(json.ToString(), "application/json")); }
public ActionResult UpdatePatch(int id, [FromBody] ProfileRequest profileRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(NoContent()); }
public void Request_Parse_NoArgs() { var request = ProfileRequest.Parse("TEST:"); Assert.Equal("TEST", request.Command); Assert.Empty(request.Args); Assert.Equal("TEST:", request.ToString()); }
public IHttpActionResult Profile([FromBody] ProfileRequest profileRequest) { profileRequest.ThrowIfNull(nameof(profileRequest)); var profileRespVm = _profileBusiness.Profile(profileRequest); return(Ok(profileRespVm)); }
public async Task <IActionResult> Profile([FromBody] ProfileRequest request) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } return(await _calculateProfileService.ProcessProfileAllocationRequest(request)); }
public async Task <IActionResult> UpdateProfile([FromBody] ProfileRequest profile) { if (!ModelState.IsValid) { return(BadRequest()); } string profileId = await _userProfileService.UpdateUserProfile(profile); return(Ok(profileId)); }
public void Request_Parse_WithArgs() { var request = ProfileRequest.Parse("TEST: arg1=1, arg2=2"); Assert.Equal("TEST", request.Command); Assert.Equal(2, request.Args.Count); Assert.Equal("1", request.Args["arg1"]); Assert.Equal("2", request.Args["arg2"]); Assert.Equal("TEST: arg1=1, arg2=2", request.ToString()); }
public ActionResult CreateAccount([FromBody] ProfileRequest request) { if (request == null) { return(BadRequest()); } var result = _profileService.CreateProfile(request); return(Ok(result)); }
public IActionResult Save([FromBody] ProfileRequest profile) { try { return(Ok(_profileService.Insert <ProfileValidator>(profile))); } catch (Exception ex) { throw ex; } }
public bool UpdateProfile(ProfileRequest profileData) { bool success = false; try { success = profileService.UpdateProfile(profileData); } catch { } return(success); }
public IActionResult Post([FromBody] ProfileRequest model) { var userId = _UserManager.GetUserId(User); var user = _Context.Users.Include(q => q.Bike).FirstOrDefault(q => q.Id == userId); user.Bike = model.Bike; user.Name = model.Name; _Context.SaveChanges(); return(Ok(model)); }
public AcApiResponse <ProfileResponse, ApiData> Profile(ProfileRequest req) { var resp = _agentConnectIntegration.Profile(req); var apiResp = new AcApiResponse <ProfileResponse, ApiData> { BusinessMetadata = MapperHelper.SetResponseProperties(resp.Payload?.Flags, DataSource.AgentConnect), ResponseData = resp }; return(apiResp); }
// GET: Profile public ActionResult Details(ProfileRequest profileRequest) { if (!string.IsNullOrEmpty(profileRequest.ProfileId)) { var profile = _profile.GetUserprofileById(Convert.ToInt64(profileRequest.ProfileId)); return(PartialView("_Profile", profile)); } else { return(null); } }
public ProfileResponse InsertProfile([FromBody] ProfileRequest request) { ProfileResponse response = new ProfileResponse(); MProfile profile = new MProfile(); List <MProfileOptions> options = new List <MProfileOptions>(); try { /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/ if (!BAplication.ValidateAplicationToken(request.ApplicationToken)) { response.Code = "2"; response.Message = Messages.ApplicationTokenNoAutorize; return(response); } /*************FIN DEL METODO*************/ BaseRequest baseRequest = new BaseRequest(); profile.Description = request.Profile.Description; foreach (MProfileOptions item in request.Options) { options.Add(item); } int ProfileId = 0; int Val = BProfile.Insert(profile, options, ref ProfileId); profile.ProfileId = ProfileId; if (Val.Equals(0)) { response.Code = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = Messages.Success; } else if (Val.Equals(2)) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = String.Format(Messages.ErrorInsert, "Profile"); } } catch (Exception ex) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = ex.Message; } response.Profile = profile; return(response); }
public async Task CreateProfile(ProfileRequest request) { var profile = new Profile { Id = new Guid(), AvatarUrl = request.AvatarUrl ?? "", FavoriteSpot = request.FavoriteSpot ?? null, Tribes = request.Tribes ?? null, UserName = request.UserName, }; await _repository.Create(profile); }
public async Task <IActionResult> SaveProfile([FromBody] ProfileRequest model) { var profile = _profileRepository.GetProfile(CurrentUserId); if (profile == null) { profile = new Profile.Profile { UserId = CurrentUserId }; } profile.DoB = model.DoB; profile.Gender = model.Gender; var measures = _measurementRepository.GetMeasures(CurrentUserId); if (model.Weight.HasValue && model.Weight != measures.FirstOrDefault(m => m.Id == Constants.Measurements.WeightId)?.LatestValue) { _measurementRepository.CreateMeasurement(new Measurement { MeasureId = Constants.Measurements.WeightId, UserId = CurrentUserId, Time = DateTimeOffset.Now, Value = model.Weight.Value }); } if (model.Height.HasValue && model.Height != measures.FirstOrDefault(m => m.Id == Constants.Measurements.HeightId)?.LatestValue) { _measurementRepository.CreateMeasurement(new Measurement { MeasureId = Constants.Measurements.HeightId, UserId = CurrentUserId, Time = DateTimeOffset.Now, Value = model.Height.Value }); } if (model.Rmr.HasValue && model.Rmr != measures.FirstOrDefault(m => m.Id == Constants.Measurements.RmrId)?.LatestValue) { _measurementRepository.CreateMeasurement(new Measurement { MeasureId = Constants.Measurements.RmrId, UserId = CurrentUserId, Time = DateTimeOffset.Now, Value = model.Rmr.Value }); } _profileRepository.SaveProfile(profile); return(await GetProfile()); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { var authToken = (string)ApplicationData.Current.LocalSettings.Values["AuthToken"]; var profileRequest = new ProfileRequest(authToken); var profileResponse = await ImaxApi.Profile(profileRequest); CustomerNameBlock.Text = profileResponse.CustomerName.FullName; CustomerIdBlock.Text = profileResponse.UserId; CardNumberBlock.Text = Ean13Generator.GenerateBarCode(profileResponse.CustomerCard); BonusesBlock.Text = profileResponse.Bonuses; } }
public ProfilesResponse GetProfilesByUser([FromBody] ProfileRequest request) { ProfilesResponse response = new ProfilesResponse(); MProfile profile = new MProfile(); List <MProfile> profiles = new List <MProfile>(); BaseRequest baseRequest = new BaseRequest(); try { /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/ if (!BAplication.ValidateAplicationToken(request.ApplicationToken)) { response.Code = "2"; response.Message = Messages.ApplicationTokenNoAutorize; return(response); } /*************FIN DEL METODO*************/ profile.UserId = request.Profile.UserId; int Val = 0; profiles = BProfile.LisByUser(profile, ref Val); if (Val.Equals(0)) { response.Code = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = Messages.Success; } else if (Val.Equals(2)) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = String.Format(Messages.ErrorObtainingReults, "Profiles"); } else { response.Code = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = String.Format(Messages.NotReults, "Profiles"); } } catch (Exception ex) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = ex.Message; } response.Profiles = profiles.ToArray(); return(response); }
public async Task <IActionResult> PostProfile([FromBody] ProfileRequest request) { var configProfile = new ConfigProfile(); configProfile.Name = request.Name; _context.Profiles.Add(configProfile); await _context.SaveChangesAsync(); return(new ObjectResult(configProfile) { StatusCode = 201 }); }
public void ProfileRequestValidator_ShouldReturnPatternWithValidRequestAAC1920() { // arrange FundingStreamPeriodProfilePattern pattern = new FundingStreamPeriodProfilePattern( "AY-1819", "PSG", "FL1", new DateTime(2019, 8, 1), new DateTime(2020, 7, 31), false, new[] { new ProfilePeriodPattern( PeriodType.CalendarMonth, "Aug", new DateTime(2019, 8, 1), new DateTime(2019, 8, 31), 2019, 1, "FY1920", 12.56m), new ProfilePeriodPattern( PeriodType.CalendarMonth, "Apr", new DateTime(2020, 4, 1), new DateTime(2020, 4, 30), 2020, 1, "FY2021", 12.56m) }, "FSP-ProfilePattern1", "FSP-ProfilePatternDescription1", RoundingStrategy.RoundDown); ProfileRequest request = new ProfileRequest( "PSG", "AY-1819", "FL1", 200); // act ProfileValidationResult validationResult = ProfileRequestValidator.ValidateRequestAgainstPattern(request, pattern); // assert validationResult .Code .Should().Be(HttpStatusCode.OK); }
public static ProfileValidationResult ValidateRequestAgainstPattern(ProfileRequest request, FundingStreamPeriodProfilePattern profilePattern) { if (profilePattern == null) { if (string.IsNullOrEmpty(request.FundingPeriodId)) { return(ProfileValidationResult.BadRequest); } return(ProfileValidationResult.NotFound); } return(ProfileValidationResult.Ok); }
public ActionResult Post([FromBody] ProfileRequest profileRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var profile = new Profile() { ProfileId = 1, Name = profileRequest.Name }; var outputModel = ToOutputModel_Links(profile); return(CreatedAtRoute("GetProfile", new { id = outputModel.Value.ProfileId }, outputModel)); }
public bool UpdateProfile(ProfileRequest profileData) { var success = false; var query = string.Format("select userId from UserDetails where (Mobile = '{1}') and userId = {2}", profileData.Email, profileData.Mobile, profileData.UserId); var existingUserId = Convert.ToInt32(dbService.ExecuteScalar(query)); if (existingUserId > 0) { query = string.Format("update UserDetails set FullName='{0}', Address='{1}', PINCode='{2}', Mobile='{3}', Email='{4}', RegistrationId = '{5}', RegisteredPHC = '{6}' output inserted.UserId where UserId={7}", profileData.FullName, profileData.Address, profileData.PinCode, profileData.Mobile, profileData.Email, profileData.RegistrationId, profileData.RegisteredPHC, profileData.UserId); var affectedUserId = Convert.ToInt32(dbService.ExecuteScalar(query)); success = (affectedUserId > 0); } return(success); }
/// <summary> /// Updates a reservation and sets the status to confirmed. /// </summary> /// <param name="reservationRequest">Reservation request</param> /// <param name="profileServiceClient">Profile service client</param> /// <returns></returns> public ReservationResponse UpdateReservation(ReservationRequest reservationRequest, IProfileServiceClient profileServiceClient) { using (Profiler.Step("ReservationServiceClient.UpdateReservation")) { var activityId = String.Empty; try { var header = ContextListBuilder.New().WithBusinessContext(ContextListAppContextSourceBusinessContext.VA) .WithUserId(reservationRequest.UserUniqueId.ToString()) .Build(); activityId = header.DiagnosticContext.ActivityId; var profileRequest = new ProfileRequest { ChainId = reservationRequest.ChainId, HotelId = reservationRequest.HotelId, TravelerProfileId = reservationRequest.GuestProfileId }; var guestProfile = profileServiceClient.GetTravelerProfile(profileRequest); using (var itineraryManagerClient = new ItineraryManagerClient(header, ServiceRegistry.AddressPool.OfType<IItineraryManager>())) { var updateReservationRq = new UpdateReservationRQ { Reservation = CreateUpdateReservationRequest(reservationRequest, guestProfile), ReturnReservationDetails = true, UserDetails = new UpdateReservationRQUserDetails { Preferences = new UpdateReservationRQUserDetailsPreferences { Language = new Language { Code = reservationRequest.Language } } } }; var updateReservationResponse = itineraryManagerClient.UpdateReservation(updateReservationRq); var reservationResponse = new ReservationResponse { ApplicationResults = new ApplicationResultsModel( updateReservationResponse.ApplicationResults.Success.IfNotNull(result => result.SystemSpecificResults.ShortText.Equals("Success"), false), updateReservationResponse.ApplicationResults.Warning.IfNotNull( applicationResultWarning => applicationResultWarning.Select(warning => warning.SystemSpecificResults.ShortText), new List<String>()), updateReservationResponse.ApplicationResults.Error.IfNotNull(applicationResultError => applicationResultError.Select(error => error.SystemSpecificResults.ShortText), new List<String>())) }; if (reservationResponse.ApplicationResults.Success) { reservationResponse.Reservation = MapReservationResponse(updateReservationResponse.ReservationList.Reservation); } return reservationResponse; } } catch (Exception exception) { Logger.AppLogger.Error( "UpdateReservationUnhandledException", exception, "ChainId".ToKvp(reservationRequest.ChainId), "HotelId".ToKvp(reservationRequest.HotelId), "UserId".ToKvp(reservationRequest.UserUniqueId)); throw HttpResponseExceptionHelper.CreateHttpResponseException(activityId, exception); } } }
public void GetStaffInfo(long uid) { ProfileRequest request = new ProfileRequest(); request.uid = uid; this.connection = ServiceUtil.Instance.Connection; this.connection.Send(PacketType.STAFF_INFO, request); }