public async Task DecrementProductAmount(ApiViewModel model) { var campaign = await FindCampaignById(model.CampaignId); // elő kellene szerezni az adott productot a neve alapján model.ProductName // a product amountból kivonni a model.Amount }
public ActionResult CandidatesDetails(int?id) { var userId = User.Identity.GetUserId(); var client = db.Clients.Where(c => c.ApplicationId == userId).Select(c => c).SingleOrDefault(); ApiViewModel api = null; List <ApiViewModel> list = null; if (client.CandidateId == id) { ViewBag.Liked = client.CandidateId; } else if (client.DislikeId == id) { ViewBag.Dislike = client.DislikeId; } ViewBag.Likes = FindLikes(id); ViewBag.Dislikes = FindDislikes(id); list = GetCandidates(); api = list.Where(c => c.Id == id).SingleOrDefault(); if (api == null) { api = new ApiViewModel(); ViewBag.NoSearch = true; } return(View(api)); }
public async Task <IActionResult> Api() { await LoadCommonValue4ViewAsync("Sample Api"); var IdToken = ""; try { //AccessToken = await _httpContextAccessor.HttpContext.GetTokenAsync("access_token"); IdToken = await _httpContextAccessor.HttpContext.GetTokenAsync("id_token"); } catch (Exception) { } var vm = new ApiViewModel { IdToken = IdToken, ApiUri = GetConfig("Dummy1RAPI"), ApiRequestHeader = "", ApiRequestRespose = "", AuthenticatedSubject = "", }; try { var jwtToken = new JwtSecurityToken(IdToken); if (jwtToken == null && jwtToken.Claims == null) { vm.VerifyMessage = "Verify error: jwt is not found data"; return(View(vm)); } var rstMessage = ""; vm.VerifyMessage = rstMessage; string certificateFilePath = GetConfig("ClientCert:Path"); string certificatePassphrase = GetConfig("ClientCert:Passphrase"); X509Certificate2 cert = new CertUtils(string.Empty) .LoadCertPfx(certificateFilePath, certificatePassphrase); vm.ApiRequestHeader = JsonFormatPretty(new { id_token = IdToken }); rstMessage = Call1RDummyAPI(IdToken, cert); vm.VerifyMessage = rstMessage; var resultObj = Convert2Object <OneRecordDummyResponse>(rstMessage); vm.VerifyResult = resultObj?.message == Constances.VERIFY_OK; vm.ApiRequestRespose = JsonFormatPrettyStr(rstMessage); vm.AuthenticatedSubject = GetAuthenSubject(rstMessage); vm.ResultData = GetDataResult(rstMessage); } catch (Exception ex) { vm.VerifyResult = false; vm.VerifyMessage = ex.Message; } return(View(vm)); }
/// <summary> /// Project a type using a DTO /// </summary> /// <typeparam name="TProjection">The dto projection</typeparam> /// <param name="item">The source entity to project</param> /// <returns>The projected type</returns> public static TProjection ProjectedAs <TProjection>(this ApiViewModel item) where TProjection : class, new() { var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <TProjection>(item)); }
public ActionResult Donation([FromBody] ApiViewModel model) { campaignService.DecrementProductAmount(model); // userService.WithdrawMoney(model); return(new OkObjectResult($"Your donation has been placed! Thank you!")); }
public List <ApiViewModel> GetEndorsements() { List <ApiViewModel> endorsements = new List <ApiViewModel>(); var response = client.GetAsync("Endorsements"); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); JArray jArray = JArray.Parse(read.Result); foreach (var item in jArray) { var endorsement = new ApiViewModel() { Id = (int)item["Id"], Issue = (string)item["Issue"], Stance = (string)item["Stance"], CandidateId = (int?)item["CandidateId"] }; endorsements.Add(endorsement); } } return(endorsements); }
public List <ApiViewModel> GetAds() { List <ApiViewModel> ads = new List <ApiViewModel>(); var response = client.GetAsync("Ads"); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); JArray jArray = JArray.Parse(read.Result); foreach (var item in jArray) { var ad = new ApiViewModel() { Id = (int)item["Id"], WebsiteUrl = (string)item["WebsiteUrl"], CandidateId = (int?)item["CandidateId"] }; ads.Add(ad); } } return(ads); }
public List <ApiViewModel> GetStaff() { List <ApiViewModel> staffs = new List <ApiViewModel>(); var response = client.GetAsync("CampaignStaffs"); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); JArray jArray = JArray.Parse(read.Result); foreach (var item in jArray) { var staff = new ApiViewModel() { Id = (int)item["Id"], Name = (string)item["Name"], Position = (string)item["Position"], Experience = (string)item["Experience"], CandidateId = (int?)item["CandidateId"] }; staffs.Add(staff); } } return(staffs); }
public List <ApiViewModel> GetFinances() { List <ApiViewModel> finances = new List <ApiViewModel>(); var response = client.GetAsync("CampaignFinances"); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); JArray jArray = JArray.Parse(read.Result); foreach (var item in jArray) { var finance = new ApiViewModel() { Id = (int)item["Id"], Amount = (double?)item["Amount"], Type = (string)item["Type"], CandidateId = (int?)item["CandidateId"] }; finances.Add(finance); } } return(finances); }
// GET: Results public HttpResponseMessage Post(EXCOViewModel ManulEntryData) { ApiViewModel sendMessage = new ApiViewModel(); try { CurrentUser user = ApiUser; AdoHelper ado = new AdoHelper(); SqlParameter param1 = new SqlParameter("@SelectedTests", ManulEntryData.SelectedTests); SqlParameter param2 = new SqlParameter("@EntryBy", user.UserName); SqlParameter param3 = new SqlParameter("@EntryDate", DateTime.Now); SqlParameter param4 = new SqlParameter("@ExcoRating", ManulEntryData.ExcoRating); SqlParameter param5 = new SqlParameter("@StartWT", ManulEntryData.StartWT); SqlParameter param6 = new SqlParameter("@FinalWT", ManulEntryData.FinalWT); SqlParameter param7 = new SqlParameter("@SpeciComment", ManulEntryData.SpeciComment); SqlParameter param8 = new SqlParameter("@Operator", ManulEntryData.Operator); SqlParameter param9 = new SqlParameter("@ExposedArea", ManulEntryData.ExposedArea); SqlParameter param10 = new SqlParameter("@StartpH", ManulEntryData.StartpH); SqlParameter param11 = new SqlParameter("@FinalpH", ManulEntryData.FinalpH); SqlParameter param12 = new SqlParameter("@TestDate", ManulEntryData.TestDate); SqlParameter param13 = new SqlParameter("@TimeHrs", ManulEntryData.TimeHrs); SqlParameter param14 = new SqlParameter("@TimeMns", ManulEntryData.TimeMns); SqlParameter param15 = new SqlParameter("@BatchNo", ManulEntryData.BatchNo); sendMessage.Message = ""; using (SqlDataReader reader = ado.ExecDataReaderProc("RNDEXCOResults_Insert", "RND", new object[] { param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15 })) { if (reader.HasRows) { while (reader.Read()) { sendMessage.Custom = Convert.ToInt32(reader["TestingNo"]); if (sendMessage.Message == "") { sendMessage.Message += sendMessage.Custom; } else { sendMessage.Message += ", " + sendMessage.Custom; } } sendMessage.Success = true; } if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open) { ado._conn.Close(); ado._conn.Dispose(); } } } catch (Exception ex) { _logger.Error(ex.Message); sendMessage.Success = false; // return new HttpResponseMessage(HttpStatusCode.InternalServerError); } return(Serializer.ReturnContent(sendMessage, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request)); }
public ApiViewModel Get(string channelId) { ApiViewModel channelDetail = new ApiViewModel(); channelDetail.channelsData = services.GetChannelDetail(channelId); channelDetail.channelsEventData = services.GetEvent(channelId); return(channelDetail); }
public HttpResponseMessage Get(string UserName, string UserAnswer) { // SqlDataReader reader = null; RNDLogin dbUser = null; ApiViewModel VM = null; try { VM = new ApiViewModel(); if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(UserAnswer)) { AdoHelper ado = new AdoHelper(); SqlParameter param1 = new SqlParameter("@UserName", UserName); SqlParameter param2 = new SqlParameter("@UserAnswer", UserAnswer); using (SqlDataReader reader = ado.ExecDataReaderProc("RNDResetPassword", "RND", new object[] { param1, param2 })) { if (reader.HasRows && reader.Read()) { dbUser = new RNDLogin(); dbUser.UserId = Convert.ToInt32(reader["UserId"]); dbUser.FirstName = Convert.ToString(reader["FirstName"]); dbUser.LastName = Convert.ToString(reader["LastName"]); dbUser.UserType = Convert.ToString(reader["UserType"]); dbUser.PermissionLevel = Convert.ToString(reader["PermissionLevel"]); dbUser.IssueDate = (!string.IsNullOrEmpty(reader["IssueDate"].ToString())) ? Convert.ToDateTime(reader["IssueDate"]) : (DateTime?)null; dbUser.CreatedBy = Convert.ToInt32(reader["CreatedBy"]); dbUser.CreatedOn = Convert.ToDateTime(reader["CreatedOn"]); dbUser.StatusCode = Convert.ToString(reader["StatusCode"]); VM.Custom = dbUser; string token = Guid.NewGuid().ToString("D") + Guid.NewGuid().ToString("D"); dbUser.UserName = UserName; dbUser.Token = token; VM.Custom = dbUser; ado = new AdoHelper(); SqlParameter param3 = new SqlParameter("@UserId", dbUser.UserId); SqlParameter param4 = new SqlParameter("@Token", token); ado.ExecScalarProc("RNDSecurityTokens_Insert", "RND", new object[] { param3, param4 }); } else { VM.Message = MessageConstants.InvalidUser; } if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open) { ado._conn.Close(); ado._conn.Dispose(); } } } } catch (Exception ex) { _logger.Error(ex.Message); return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } return(Serializer.ReturnContent(VM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request)); }
public MainWindow() { ApiViewModel apiViewModel = new ApiViewModel(); var dataResult = apiViewModel.GetWeatherForcast(); var weatherData = apiViewModel.GetTemps(dataResult); Resources["WeatherData"] = weatherData; InitializeComponent(); }
public PanelApi() { InitializeComponent(); if (apiVM == null) { apiVM = new ApiViewModel(); } DataContext = apiVM; }
public async Task <IActionResult> Api() { var user = await GetUser(required : true); var model = new ApiViewModel { User = user, ApiKeys = _context.ApiKeys.Where(d => d.ApplicationUserId == user.Id).ToList(), }; return(View(model)); }
public IActionResult SwearWordTagger(ApiViewModel model) { var apiOutput = CallApi($"{_urlPath}TextRefinement/SwearWordTagger", model.InputText); if (apiOutput.Item2) { var viewModel = JsonConvert.DeserializeObject <Dictionary <string, string> >(apiOutput.Item1); return(PartialView("_SwearTaggerOutput", viewModel)); } else { ShowError(apiOutput.Item1); return(new EmptyResult()); } }
public IActionResult FormalConverter(ApiViewModel model) { var apiOutput = CallApi($"{_urlPath}TextRefinement/FormalConverter", model.InputText); if (apiOutput.Item2) { ViewData["Output"] = apiOutput.Item1; return(PartialView("_ApiOutput")); } else { ShowError(apiOutput.Item1); return(new EmptyResult()); } }
public IActionResult LemmatizeText2Text(ApiViewModel model) { var result = CallApi($"{_urlPath}Stemmer/LemmatizeText2Text", model.InputText); if (result.Item2) { ViewData["Output"] = result.Item1; return(PartialView("_ApiOutput")); } else { ShowError(result.Item1); return(new EmptyResult()); } }
public IActionResult LanguageDetectionPredict(ApiViewModel model) { var result = CallApi($"{_urlPath}LanguageDetection/Predict", model.InputText); if (result.Item2) { ViewData["Output"] = result.Item1; return(PartialView("_ApiOutput")); } else { ShowError(result.Item1); return(new EmptyResult()); } }
public IActionResult NamedEntityRecognitionDetect(ApiViewModel model) { var apiOutput = CallApi($"{_urlPath}NamedEntityRecognition/Detect", model.InputText); if (apiOutput.Item2) { var viewModel = JsonConvert.DeserializeObject <List <Phrase> >(apiOutput.Item1); return(PartialView("_NamedEntityRecognitionDetectOutput", viewModel)); } else { ShowError(apiOutput.Item1); return(new EmptyResult()); } }
public IActionResult SentimentClassifier(ApiViewModel model) { var apiOutput = CallApi($"{_urlPath}SentimentAnalyzer/SentimentClassifier", model.InputText); if (apiOutput.Item2) { var viewModel = JsonConvert.DeserializeObject <int>(apiOutput.Item1); return(PartialView("_SentimentClassifierOutput", viewModel)); } else { ShowError(apiOutput.Item1); return(new EmptyResult()); } }
public ActionResult Compare(string name, string name2) { var list = ConvertName(name); var list2 = ConvertName(name2); var candidates = GetCandidates(); ApiViewModel person = null; ApiViewModel person2 = null; int candidateId = 0; int candidate2Id = 0; if (list.Count > 1) { var first = list[0]; var last = list.Last(); candidateId = candidates.Where(c => c.Name.Contains(first) && c.Name.Contains(last)).Select(c => c.Id).SingleOrDefault(); } else { var candids = candidates.Where(c => c.Name.Contains(list[0])).Select(c => c).ToList(); if (candids.Count > 1) { person = candids.FirstOrDefault(); } else { candidateId = candidates.Where(c => c.Name.Contains(list[0])).Select(c => c.Id).SingleOrDefault(); } } if (list2.Count > 1) { var first = list2[0]; var last = list2.Last(); candidate2Id = candidates.Where(c => c.Name.Contains(first) && c.Name.Contains(last)).Select(c => c.Id).SingleOrDefault(); } else { var candids2 = candidates.Where(c => c.Name.Contains(list2[0])).Select(c => c).ToList(); if (candids2.Count > 1) { person2 = candids2.FirstOrDefault(); } else { candidate2Id = candidates.Where(c => c.Name.Contains(list2[0])).Select(c => c.Id).SingleOrDefault(); } } return(RedirectToAction("CompCandidates", new { id = candidateId, id2 = candidate2Id })); }
public async Task <ApiViewModel> SaveJavlibraryCookie(string cookie, string userAgent) { ApiViewModel ret = new ApiViewModel(); try { await JavLibraryService.SaveJavLibraryCookie(cookie, userAgent); } catch (Exception ee) { ret.status = ApiViewModelStatus.Exception; ret.msg = ee.ToString(); } return(ret); }
public List <ApiViewModel> Get(ApiCall call) { List <ApiViewModel> result = new List <ApiViewModel>(); foreach (var item in ApiContainer.List) { if (item.Key != this.ModelName) { ApiViewModel model = new ApiViewModel(); model.Name = item.Key; model.Url = "/_api/help/list/" + item.Key; result.Add(model); } } return(result); }
public ActionResult SecuityConfig(RNDUserSecurityAnswer model) { string message = ""; bool isSuccess = false; try { //start here var client = GetHttpClient(); var task = client.PutAsJsonAsync(Api + "api/login", model).ContinueWith((res) => { if (res.Result.IsSuccessStatusCode) { ApiViewModel VM = JsonConvert.DeserializeObject <ApiViewModel>(res.Result.Content.ReadAsStringAsync().Result); if (VM != null) { if (!string.IsNullOrEmpty(VM.Message)) { message = VM.Message; } else if (VM.Custom != null) { message = VM.Custom.Password; isSuccess = true; LoggedInUser.IsSecurityApplied = true; } if (isSuccess && this.HttpContext.Session["CurrentUser"] != null) { CurrentUser currentUser = (CurrentUser)this.HttpContext.Session["CurrentUser"]; currentUser.StatusCode = VM.Custom.StatusCode; this.HttpContext.Session["CurrentUser"] = currentUser; } } } }); task.Wait(); } catch (Exception ex) { _logger.Error(ex.Message); } return(RedirectToAction("WorkSutdyList", "WorkStudy")); }
public async Task <IActionResult> ApiDelete(ApiViewModel model) { var user = await GetUser(required : true); if (model.DeleteApiKey != null) { var apikey = _context.ApiKeys.SingleOrDefault(d => d.Key == model.DeleteApiKey && d.ApplicationUserId == user.Id); if (apikey != null) { _context.ApiKeys.Remove(apikey); _context.SaveChanges(); this.FlashSuccess($"Deleted API KEY ({apikey.Name})"); return(RedirectToAction(nameof(Api))); } } this.FlashError($"Failed to delete API KEY"); return(RedirectToAction(nameof(Api))); }
public async Task <IActionResult> CriarLink(ApiViewModel model) { if (ModelState.IsValid) { items Item = new items() { id = Guid.NewGuid().ToString(), title = model.title, unit_price = model.unit_price, quantity = model.quantity, tangible = model.tangible }; LinkPagamento novo = new LinkPagamento() { api_key = configuration.GetConnectionString("ApiKey"), name = model.name, amount = model.amount, payment_Config = new payment_config() { boleto = new boleto() { enabled = model.enabledboleto, expires_in = model.expires_in }, credit_Card = new credit_card() { enabled = model.enabledCard, free_installments = model.free_installments, interest_rate = model.interest_rate, max_installments = model.max_installments } } }; novo.AddItem(Item); var resultado = await criarLink(novo); Console.WriteLine(resultado); return(RedirectToAction("")); } return(View()); }
/// <summary> /// Retrieve the UAC details /// </summary> /// <param name="material"></param> /// <returns></returns> public HttpResponseMessage Post(RNDMaterial material) { ApiViewModel VM = null; try { CurrentUser user = ApiUser; VM = new ApiViewModel(); if (material != null && !string.IsNullOrEmpty(material.records)) // if (material.RecID > 0) { AdoHelper ado = new AdoHelper(); SqlParameter param1 = new SqlParameter("@Ids", material.records); SqlParameter param2 = new SqlParameter("@WorkStudyID", material.WorkStudyID); SqlParameter param3 = new SqlParameter("@SoNum", material.SoNum); SqlParameter param4 = new SqlParameter("@MillLotNo", material.MillLotNo); SqlParameter param5 = new SqlParameter("@CustPart", material.CustPart); SqlParameter param6 = new SqlParameter("@UACPart", material.UACPart); SqlParameter param7 = new SqlParameter("@Alloy", material.Alloy); SqlParameter param8 = new SqlParameter("@Temper", material.Temper); SqlParameter param9 = new SqlParameter("@Hole", material.Hole); SqlParameter param10 = new SqlParameter("@PieceNo", material.PieceNo); SqlParameter param11 = new SqlParameter("@Comment", material.Comment); SqlParameter param12 = new SqlParameter("@DBCntry", material.DBCntry); SqlParameter param13 = new SqlParameter("@EntryBy", user.UserName); ado.ExecScalarProc("RNDUACPartListing_Insert", "RND", new object[] { param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13 }); VM.Message = MessageConstants.Saved; VM.Success = true; } } catch (Exception ex) { _logger.Error(ex.Message); return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } return(Serializer.ReturnContent(VM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request)); }
public List <ApiViewModel> GetCandidates() { List <ApiViewModel> candidates = new List <ApiViewModel>(); var response = client.GetAsync("Candidates"); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); JArray jArray = JArray.Parse(read.Result); foreach (var item in jArray) { var candidate = new ApiViewModel() { Id = (int)item["Id"], Name = (string)item["Name"], Description = (string)item["Description"], Gender = (string)item["Gender"], Occupation = (string)item["Occupation"], Birthdate = (string)item["Birthdate"], BirthPlace = (string)item["BirthPlace"], Hometown = (string)item["Hometown"], Religion = (string)item["Religion"], MaritalStatus = (string)item["MaritalStatus"], Children = (string)item["Children"], Education = (string)item["Education"], Polling = (double?)item["Polling"], ImgPath = (string)item["ImgPath"], Party = (string)item["Party"] }; candidates.Add(candidate); } } return(candidates); }
public ApiViewModel <CategoryViewModel> Create(string categoryName) { ApiViewModel <CategoryViewModel> model; if (!string.IsNullOrWhiteSpace(categoryName)) { model = new ApiViewModel <CategoryViewModel>() { ApiStatusCode = StatusCode.OK, Data = Mapper.Map <CategoryViewModel>(_categoryService.Create(categoryName)), ResponseMessage = string.Empty }; } else { model = new ApiViewModel <CategoryViewModel>() { ApiStatusCode = StatusCode.Dupplicate, Data = null, ResponseMessage = string.Format("{0} is {1}", ResponseMessageText.CATEGORY_NAME, ResponseMessageText.IS_DUPPLICATED) }; } return(model); }