public async Task <IActionResult> GetBySlug(string slug) => (await _articlesService.GetBySlugAsync(CurrentUserId.SomeNotNull(), slug)) .Match <IActionResult>(article => Ok(new { article }), NotFound);
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1"); //scriptManager.Scripts.Add(new ScriptReference {Path = ResolveUrl("~/assets/js/jquery.flot.min.js")}); //scriptManager.Scripts.Add(new ScriptReference {Path = ResolveUrl("~/assets/js/jquery.flot.time.min.js")}); //GetChart(); } // request LinqDataSourceRequest.WhereParameters.Clear(); LinqDataSourceRequest.WhereParameters.Add("CurrentUserId", DbType.Int32, CurrentUserId.ToString()); LinqDataSourceRequest.Where = "ApprovalUser == @CurrentUserId && CreatedId == @CurrentUserId"; // approval LinqDataSourceApproval.WhereParameters.Clear(); LinqDataSourceApproval.WhereParameters.Add("CurrentUserId", DbType.Int32, CurrentUserId.ToString()); LinqDataSourceApproval.WhereParameters.Add("IsApprovalRequest", DbType.Boolean, Boolean.TrueString); LinqDataSourceApproval.WhereParameters.Add("ApprovalStatusCanceled", DbType.Int32, ((int)CConstValue.ApprovalStatus.Canceled).ToString()); LinqDataSourceApproval.WhereParameters.Add("ApprovalStatusRejected", DbType.Int32, ((int)CConstValue.ApprovalStatus.Rejected).ToString()); LinqDataSourceApproval.Where = "ApprovalStep = null && IsApprovalRequest == @IsApprovalRequest && (ApprovalUser = Supervisor) && Supervisor == @CurrentUserId && (ApprovalStatus != @ApprovalStatusCanceled && ApprovalStatus != @ApprovalStatusRejected)"; }
public async Task <IActionResult> GetComments(string slug) => (await _commentsService.GetCommentsForArticle(CurrentUserId.SomeNotNull(), slug)) .Match <IActionResult>(comments => Ok(new { comments }), Error);
public async Task <IActionResult> Get(GetArticlesModel request) { var articles = await _articlesService.GetAsync(CurrentUserId.SomeNotNull(), request); return(Ok(new { articles, articlesCount = articles.Length })); }
public void VsixManagePluginTriggersTest() { var packageSettings = GetTestPackageSettings(); DeployAssembly(packageSettings); var assemblyRecord = GetTestPluginAssemblyRecords().First(); DeletePluginTriggers(assemblyRecord); //add one update trigger RunDialogAndAddMessage("Update"); //verify trigger created var triggers = GetPluginTriggers(assemblyRecord); Assert.AreEqual(1, triggers.Count()); Assert.IsTrue(triggers.First().GetBoolField(Fields.sdkmessageprocessingstep_.asyncautodelete)); Assert.IsNull(triggers.First().GetStringField(Fields.sdkmessageprocessingstep_.filteringattributes)); Assert.IsNull(triggers.First().GetStringField(Fields.sdkmessageprocessingstep_.impersonatinguserid)); //verify preimage created for update with all fields var image = XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, triggers.First().Id); Assert.IsNotNull(image); Assert.IsNull(image.GetStringField(Fields.sdkmessageprocessingstepimage_.attributes)); Assert.AreEqual("PreImage", image.GetStringField(Fields.sdkmessageprocessingstepimage_.entityalias)); //add one create trigger RunDialogAndAddMessage("Create"); //verify created triggers = GetPluginTriggers(assemblyRecord); Assert.AreEqual(2, triggers.Count()); //delete a trigger var dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); var entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); var triggersSubGrid = entryViewModel.SubGrids.First(); triggersSubGrid.GridRecords.First().DeleteRow(); Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); //verify deleted triggers = GetPluginTriggers(assemblyRecord); Assert.AreEqual(1, triggers.Count()); //add 2 update triggers RunDialogAndAddMessage("Update"); RunDialogAndAddMessage("Update"); triggers = GetPluginTriggers(assemblyRecord); Assert.AreEqual(3, triggers.Count()); //okay now lets inspect and adjust the filtering attributes and preimages and impersonating user in one of the update messages dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); triggersSubGrid = entryViewModel.SubGrids.First(); var updateRows = triggersSubGrid.GridRecords.Where(r => r.GetLookupFieldFieldViewModel(nameof(PluginTrigger.Message)).Value.Name == "Update"); var letsAdjustThisOne = updateRows.First(); //set no not all preimage fields letsAdjustThisOne.GetBooleanFieldFieldViewModel(nameof(PluginTrigger.PreImageAllFields)).Value = false; //set some arbitrary other image name letsAdjustThisOne.GetStringFieldFieldViewModel(nameof(PluginTrigger.PreImageName)).Value = "FooOthername"; //set some specific fields in the preimage var preImageFieldsField = letsAdjustThisOne.GetFieldViewModel <RecordFieldMultiSelectFieldViewModel>(nameof(PluginTrigger.PreImageFields)); preImageFieldsField.MultiSelectsVisible = true; preImageFieldsField.DynamicGridViewModel.GridRecords.ElementAt(1).GetBooleanFieldFieldViewModel(nameof(RecordFieldMultiSelectFieldViewModel.SelectablePicklistOption.Select)).Value = true; preImageFieldsField.DynamicGridViewModel.GridRecords.ElementAt(3).GetBooleanFieldFieldViewModel(nameof(RecordFieldMultiSelectFieldViewModel.SelectablePicklistOption.Select)).Value = true; //set some specific filtering attributes var filteringAttributesField = letsAdjustThisOne.GetFieldViewModel <RecordFieldMultiSelectFieldViewModel>(nameof(PluginTrigger.FilteringFields)); filteringAttributesField.MultiSelectsVisible = true; filteringAttributesField.DynamicGridViewModel.GridRecords.ElementAt(1).GetBooleanFieldFieldViewModel(nameof(RecordFieldMultiSelectFieldViewModel.SelectablePicklistOption.Select)).Value = true; filteringAttributesField.DynamicGridViewModel.GridRecords.ElementAt(3).GetBooleanFieldFieldViewModel(nameof(RecordFieldMultiSelectFieldViewModel.SelectablePicklistOption.Select)).Value = true; //set impersonating user var impersonatingUserField = letsAdjustThisOne.GetLookupFieldFieldViewModel(nameof(PluginTrigger.SpecificUserContext)); impersonatingUserField.SelectedItem = impersonatingUserField.ItemsSource.First(p => p.Record?.Id == CurrentUserId.ToString()); //save Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); //verify still 3 triggers triggers = GetPluginTriggers(assemblyRecord); Assert.AreEqual(3, triggers.Count()); //get the record we updated var updatedTriggerMatches = triggers.Where(t => t.GetStringField(Fields.sdkmessageprocessingstep_.filteringattributes) != null); Assert.AreEqual(1, updatedTriggerMatches.Count()); var updatedTrigger = updatedTriggerMatches.First(); //verify the filtering and image fields we set got saved correctly Assert.IsNotNull(updatedTrigger.GetStringField(Fields.sdkmessageprocessingstep_.filteringattributes)); Assert.AreEqual(CurrentUserId.ToString(), updatedTrigger.GetLookupId(Fields.sdkmessageprocessingstep_.impersonatinguserid)); image = XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, updatedTrigger.Id); Assert.IsNotNull(image); Assert.IsNotNull(image.GetStringField(Fields.sdkmessageprocessingstepimage_.attributes)); Assert.AreEqual("FooOthername", image.GetStringField(Fields.sdkmessageprocessingstepimage_.entityalias)); //lets just verify if we go through te dialog without touching the record we adjusted that it is still the same after the save dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); updatedTrigger = XrmRecordService.Get(updatedTrigger.Type, updatedTrigger.Id); Assert.IsNotNull(updatedTrigger.GetStringField(Fields.sdkmessageprocessingstep_.filteringattributes)); Assert.AreEqual(CurrentUserId.ToString(), updatedTrigger.GetLookupId(Fields.sdkmessageprocessingstep_.impersonatinguserid)); XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, triggers.First().Id); Assert.IsNotNull(image); Assert.IsNotNull(image.GetStringField(Fields.sdkmessageprocessingstepimage_.attributes)); Assert.AreEqual("FooOthername", image.GetStringField(Fields.sdkmessageprocessingstepimage_.entityalias)); //now lets verify deletion of an image if changed to not have one (image deleted) as well as clear impersonating user dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); triggersSubGrid = entryViewModel.SubGrids.First(); letsAdjustThisOne = triggersSubGrid.GridRecords.First(r => r.GetRecord().GetStringField(nameof(PluginTrigger.Id)) == updatedTrigger.Id); impersonatingUserField = letsAdjustThisOne.GetLookupFieldFieldViewModel(nameof(PluginTrigger.SpecificUserContext)); impersonatingUserField.SelectedItem = impersonatingUserField.ItemsSource.First(p => p.Record == null); //set no not all preimage fields letsAdjustThisOne.GetBooleanFieldFieldViewModel(nameof(PluginTrigger.PreImageAllFields)).Value = false; //set no fields on the preimage preImageFieldsField = letsAdjustThisOne.GetFieldViewModel <RecordFieldMultiSelectFieldViewModel>(nameof(PluginTrigger.PreImageFields)); preImageFieldsField.MultiSelectsVisible = true; foreach (var field in preImageFieldsField.DynamicGridViewModel.GridRecords) { field.GetBooleanFieldFieldViewModel(nameof(RecordFieldMultiSelectFieldViewModel.SelectablePicklistOption.Select)).Value = false; } //save Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); //verify now no impersonation updatedTrigger = XrmRecordService.Get(updatedTrigger.Type, updatedTrigger.Id); Assert.IsNull(updatedTrigger.GetLookupId(Fields.sdkmessageprocessingstep_.impersonatinguserid)); //verify no image image = XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, updatedTrigger.Id); Assert.IsNull(image); //lets just verify if we go through te dialog without touching the record still doesn't have one dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); //verify still no impersonation updatedTrigger = XrmRecordService.Get(updatedTrigger.Type, updatedTrigger.Id); Assert.IsNull(updatedTrigger.GetLookupId(Fields.sdkmessageprocessingstep_.impersonatinguserid)); //verify still no image image = XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, updatedTrigger.Id); Assert.IsNull(image); //add the image again dialog = new ManagePluginTriggersDialog(CreateDialogController(), new FakeVisualStudioService(), XrmRecordService, packageSettings); dialog.Controller.BeginDialog(); entryViewModel = (ObjectEntryViewModel)dialog.Controller.UiItems.First(); triggersSubGrid = entryViewModel.SubGrids.First(); letsAdjustThisOne = triggersSubGrid.GridRecords.First(r => r.GetRecord().GetStringField(nameof(PluginTrigger.Id)) == updatedTrigger.Id); //set no not all preimage fields letsAdjustThisOne.GetBooleanFieldFieldViewModel(nameof(PluginTrigger.PreImageAllFields)).Value = true; //save Assert.IsTrue(entryViewModel.Validate()); entryViewModel.OnSave(); //verify image created image = XrmRecordService.GetFirst(Entities.sdkmessageprocessingstepimage, Fields.sdkmessageprocessingstepimage_.sdkmessageprocessingstepid, updatedTrigger.Id); Assert.IsNotNull(image); Assert.IsNull(image.GetStringField(Fields.sdkmessageprocessingstepimage_.attributes)); var solutionComponents = XrmRecordService.GetSolutionComponents(packageSettings.Solution.Id, OptionSets.SolutionComponent.ObjectTypeCode.SDKMessageProcessingStep); Assert.IsTrue(triggers.All(t => solutionComponents.Contains(t.Id))); }
public void RecordCountTest() { var accountLabel = XrmService.GetEntityDisplayName(Entities.account); DeleteAll(Entities.account); var account1 = CreateAccount(); var account2 = CreateAccount(); var account3 = CreateAccount(); XrmService.Assign(account3, NotCurrentUserId); //okay script through generation of various requests //create test application with module loaded var testApplication = CreateAndLoadTestApplication <RecordCountsModule>(); var request = new RecordCountsRequest(); request.AllRecordTypes = true; request.GroupCountsByOwner = false; //verify dialog processes var response = testApplication.NavigateAndProcessDialog <RecordCountsModule, RecordCountsDialog, RecordCountsResponse>(request); //verify response counts Assert.IsTrue(response.RecordCounts.Count() > 10); Assert.AreEqual(1, response.RecordCounts.Count(r => r.RecordType == accountLabel)); var accountCount = response.RecordCounts.First(r => r.RecordType == accountLabel); Assert.AreEqual(3, accountCount.Count); request = new RecordCountsRequest(); request.AllRecordTypes = true; request.GroupCountsByOwner = true; //verify dialog processes response = testApplication.NavigateAndProcessDialog <RecordCountsModule, RecordCountsDialog, RecordCountsResponse>(request); //verify response counts Assert.IsTrue(response.RecordCounts.Count() > 10); var accountCounts = response.RecordCounts.Where(r => r.RecordType == accountLabel); Assert.AreEqual(2, accountCounts.Count()); Assert.IsTrue(accountCounts.All(r => r is RecordCountByOwner)); Assert.AreEqual(2, accountCounts.Cast <RecordCountByOwner>().Select(r => r.Owner).Distinct().Count()); Assert.AreEqual(1, accountCounts.Where(r => r.Count == 1).Count()); Assert.AreEqual(1, accountCounts.Where(r => r.Count == 2).Count()); FileUtility.DeleteFiles(TestingFolder); Assert.IsFalse(FileUtility.GetFiles(TestingFolder).Any()); request.AllRecordTypes = false; request.RecordTypes = new[] { new RecordTypeSetting(Entities.account, Entities.account) }; //verify dialog processes response = testApplication.NavigateAndProcessDialog <RecordCountsModule, RecordCountsDialog, RecordCountsResponse>(request); //verify response counts Assert.IsTrue(response.RecordCounts.All(r => r.RecordType == accountLabel)); accountCounts = response.RecordCounts.Where(r => r.RecordType == accountLabel); Assert.AreEqual(2, accountCounts.Count()); Assert.IsTrue(accountCounts.All(r => r is RecordCountByOwner)); Assert.AreEqual(2, accountCounts.Cast <RecordCountByOwner>().Select(r => r.Owner).Distinct().Count()); Assert.AreEqual(1, accountCounts.Where(r => r.Count == 1).Count()); Assert.AreEqual(1, accountCounts.Where(r => r.Count == 2).Count()); request.AllRecordTypes = true; request.OnlyIncludeSelectedOwner = true; request.Owner = new Lookup(Entities.systemuser, CurrentUserId.ToString(), "Current User"); //verify dialog processes response = testApplication.NavigateAndProcessDialog <RecordCountsModule, RecordCountsDialog, RecordCountsResponse>(request); //verify response counts var userName = (string)XrmService.LookupField(Entities.systemuser, CurrentUserId, Fields.systemuser_.fullname); Assert.IsTrue(response.RecordCounts.Any()); Assert.IsTrue(response.RecordCounts.All(rc => rc is RecordCountByOwner)); Assert.IsTrue(response.RecordCounts.Cast <RecordCountByOwner>().All(rc => rc.Owner == userName)); Assert.AreEqual(1, response.RecordCounts.Count(r => r.RecordType == accountLabel)); accountCount = response.RecordCounts.First(r => r.RecordType == accountLabel); Assert.IsTrue(accountCount is RecordCountByOwner); Assert.AreEqual(2, accountCount.Count); }
public ActionResult SaveSafetyItem(VmTeamSaveSafetyItem teamSaveSafetyItem) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); string attachedFileUrl = string.Empty; try { if (ModelState.IsValid) { if (teamSaveSafetyItem.UploadedAttachedFile != null) { attachedFileUrl = UIHelper.UploadFile(teamSaveSafetyItem.UploadedAttachedFile, "/Resources/Uploaded/TeamSafetyItems/AttachedFile/" + CurrentUserId.Replace("-", "")); } else { attachedFileUrl = teamSaveSafetyItem.OldAttachedFileUrl; } blTeamSafetyItem.UpdateTeamSafetyItem(new VmTeamSafetyItem { TeamId = teamSaveSafetyItem.TeamId, SafetyItemId = teamSaveSafetyItem.SafetyItemId, LastContent = teamSaveSafetyItem.DescriptionContent ?? "", ItemStatus = 0, AttachedFileUrl = attachedFileUrl, Type = false, UserId = CurrentUserId, }); } } catch (Exception ex) { result = false; } //if (result != false && !string.IsNullOrEmpty(attachedFileUrl)) //{ // UIHelper.DeleteFile(teamSaveSafetyItem.OldAttachedFileUrl); //} var jsonData = new { attachedFileUrl, success = result, message = "Your attached file uploaded." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); //return View("../Author/TeamSafetyItemEdit", model); }
public void SetViewType(LinqDataSource linqDataSource, RadGrid radGrid) { string whereString = string.Empty; object selectedText = ViewState["SelectedTextView"]; if (selectedText == null) { selectedText = "All"; } linqDataSource.TableName = GetTableNameForViewType(selectedText.ToString()); var approvalUserNameColumn = radGrid.Columns.FindByUniqueNameSafe("ApprovalUserName"); switch (selectedText.ToString()) { // All case "All": linqDataSource.OrderBy = "CreatedDate Desc"; if (approvalUserNameColumn != null) { approvalUserNameColumn.Visible = false; } break; // My Request case "My Request": linqDataSource.WhereParameters.Add("CreatedId", DbType.Int32, CurrentUserId.ToString()); whereString = "CreatedId == @CreatedId"; if (linqDataSource.Where.Length > 0) { whereString += " && "; } linqDataSource.Where = linqDataSource.Where.Insert(0, whereString); linqDataSource.OrderBy = "CreatedDate Desc"; if (approvalUserNameColumn != null) { approvalUserNameColumn.Visible = false; } break; // My Approval case "My Approval": linqDataSource.WhereParameters.Add("ApprovalUser", DbType.Int32, CurrentUserId.ToString()); linqDataSource.WhereParameters.Add("IsApprovalRequest", DbType.Boolean, bool.TrueString); linqDataSource.WhereParameters.Add("CreatedId", DbType.Int32, CurrentUserId.ToString()); whereString = "(ApprovalUser == @ApprovalUser && IsApprovalRequest == @IsApprovalRequest && CreatedId != @CreatedId)"; if (linqDataSource.Where.Length > 0) { whereString += " && "; } linqDataSource.Where = linqDataSource.Where.Insert(0, whereString); linqDataSource.OrderBy = "ApprovalStatus, CreatedDate Desc"; if (approvalUserNameColumn != null) { approvalUserNameColumn.Visible = true; } break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FileDownloadList1.InitFileDownloadList((int)CConstValue.Upload.Student); LoadSite(CurrentSiteId); LoadSiteLocation(CurrentSiteId); var global = new CGlobal(); ddlCountry.DataSource = global.GetCountry(); ddlCountry.DataTextField = "Name"; ddlCountry.DataValueField = "Value"; ddlCountry.Filter = (RadComboBoxFilter)Convert.ToInt32(1); ddlCountry.DataBind(); ddlCountry.SelectedIndex = 35; //canada ddlPerCountry.DataSource = global.GetCountry(); ddlPerCountry.DataTextField = "Name"; ddlPerCountry.DataValueField = "Value"; ddlPerCountry.Filter = (RadComboBoxFilter)Convert.ToInt32(1); ddlPerCountry.DataBind(); ddlPerCountry.SelectedIndex = 35; // canada ddlStatus.DataSource = global.GetDictionary(15); ddlStatus.DataTextField = "Name"; ddlStatus.DataValueField = "Value"; ddlStatus.DataBind(); ddlStatus.SelectedIndex = 0; ddlPermit.DataSource = global.GetDictionary(16); ddlPermit.DataTextField = "Name"; ddlPermit.DataValueField = "Value"; ddlPermit.DataBind(); ddlPermit.SelectedIndex = 0; var marketer = new CUser(); ddlmarketer.DataSource = marketer.GetMarketerList(CurrentSiteId); ddlmarketer.DataTextField = "Name"; ddlmarketer.DataValueField = "Value"; ddlmarketer.DataBind(); ddlmarketer.Items.Insert(0, new RadComboBoxItem("N/A", null)); bool isSelected = false; foreach (RadComboBoxItem item in ddlmarketer.Items) { if (item.Value == CurrentUserId.ToString()) { item.Selected = true; isSelected = true; break; } } if (isSelected == false) { ddlmarketer.SelectedIndex = 0; } tbInsuranceStartDate.Enabled = false; tbInsuranceEndtDate.Enabled = false; tbInsuranceDayFee.Enabled = false; tbInsuranceTotalAmt.Enabled = false; } }
public ActionResult UploadReferenceFile(HttpPostedFileBase uploadedReferenceFile, string title) { var result = true; var blReference = new BLReference(); var referenceFileUrl = ""; try { if (ModelState.IsValid) { if (uploadedReferenceFile != null) { referenceFileUrl = UIHelper.UploadFile(uploadedReferenceFile, "/Resources/Uploaded/TeamSafetyItems/ReferenceFile/" + CurrentUserId.Replace("-", "")); } blReference.CreateReference( new VmReference { ReferenceFileUrl = referenceFileUrl, Title = title, }); } } catch (Exception ex) { result = false; } var jsonData = new { success = result, message = "Your reference file uploaded." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); //return View("../Author/TeamSafetyItemEdit", model); }
/// <inheritdoc /> public async Task <ClaimPaymentContext> InitiateClaimPaymentAsync(ClaimPaymentRequest request) { // Loading claim var claim = await GetClaimAsync(request.ProjectId, request.ClaimId); // Checking access rights if (claim.PlayerUserId != CurrentUserId) { throw new NoAccessToProjectException(claim.Project, CurrentUserId); } PaymentType onlinePaymentType = claim.Project.ActivePaymentTypes.SingleOrDefault( pt => pt.TypeKind == PaymentTypeKind.Online); if (onlinePaymentType == null) { throw new OnlinePaymentsNotAvailable(claim.Project); } if (request.Money <= 0) { throw new PaymentException(claim.Project, $"Money amount must be positive integer"); } User user = await GetCurrentUser(); var message = new PaymentMessage { Amount = request.Money, Details = $"Билет (организационный взнос) участника на «{claim.Project.ProjectName}»", CustomerAccount = CurrentUserId.ToString(), CustomerEmail = user.Email, CustomerPhone = user.Extra?.PhoneNumber, CustomerComment = request.CommentText, PaymentMethod = PscbPaymentMethod.BankCards, SuccessUrl = _uriService.Get(new PaymentSuccessUrl(request.ProjectId, request.ClaimId)), FailUrl = _uriService.Get(new PaymentFailUrl(request.ProjectId, request.ClaimId)), Data = new PaymentMessageData { Receipt = new Receipt { CompanyEmail = User.OnlinePaymentVirtualUser, TaxSystem = TaxSystemType.SimplifiedIncomeOutcome, Items = new List <ReceiptItem> { new ReceiptItem { ObjectType = PaymentObjectType.Service, PaymentType = ItemPaymentType.FullPayment, Price = request.Money, Quantity = 1, TotalPrice = request.Money, VatType = VatSystemType.None, Name = claim.Project.ProjectName, } } } } }; // Creating request to bank PaymentRequestDescriptor result = await GetApi(request.ProjectId, request.ClaimId) .BuildPaymentRequestAsync( message, async() => (await AddPaymentCommentAsync(claim.CommentDiscussion, onlinePaymentType, request)) .CommentId .ToString() .PadLeft(10, '0') ); return(new ClaimPaymentContext { Accepted = true, RequestDescriptor = result }); }
public ActionResult Create(VmTask model) { var result = -1; var blTask = new BLTask(); try { if (ModelState.IsValid) { if (model.UploadedDocument != null) { Image image = Image.FromStream(model.UploadedDocument.InputStream); Bitmap bitmap = new Bitmap(image); ResizePicture(ref bitmap); model.ImageUrl = UIHelper.UploadPictureFile(bitmap, model.UploadedDocument.FileName, model.UploadedDocument.ContentLength, model.UploadedDocument.ContentType, "/Resources/Uploaded/Tasks/" + CurrentUserId.Replace("-", "")); } } result = blTask.CreateTask(model); } catch (Exception ex) { result = -1; } if (result != -1) { return(RedirectToAction("tl", "Admin", new { activeItemId = result })); } model.ActionMessageHandler.Message = "Operation has been failed...\n"; return(View("../Admin/CreateTask", model)); }
public ActionResult EditTask(VmTask model) { model.CurrentUserId = CurrentUserId; var oldUrl = model.ImageUrl; var result = true; var blTask = new BLTask(); try { if (ModelState.IsValid) { if (model.UploadedDocument != null) { Image image = Image.FromStream(model.UploadedDocument.InputStream); Bitmap bitmap = new Bitmap(image); ResizePicture(ref bitmap); model.ImageUrl = UIHelper.UploadPictureFile(bitmap, model.UploadedDocument.FileName, model.UploadedDocument.ContentLength, model.UploadedDocument.ContentType, "/Resources/Uploaded/Tasks/" + CurrentUserId.Replace("-", "")); } } result = blTask.UpdateTask(model); } catch (Exception ex) { result = false; } //if (result != false && !string.IsNullOrEmpty(model.ImageUrl)) //{ // UIHelper.DeleteFile(oldUrl); //} if (result == false) { model.ActionMessageHandler.Message = "Operation has been failed...\n call system Admin"; } var jsonData = new { TaskTitle = model.Name, TaskIconUrl = model.ImageUrl, TaskId = model.Id, success = result, message = model.ActionMessageHandler.Message = "Operation has been succeeded" }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); //return View("../Author/TaskEdit", model); }
private async void GetUsersPrescriptions() { PatientsPrescriptions.Clear(); var allPrescriptions = blockChainHandler.GetAllPrescriptionsByPatient(CurrentUserId.ToString()); var realisedPrescriptions = blockChainHandler.GetAllRealizedPrescriptionsByPatient(CurrentUserId.ToString()); if (allPrescriptions == null || realisedPrescriptions == null) { MessageBox.Show("Blockchain unavailable, signing out.."); MainViewModel.LogOut(); } foreach (var prescription in allPrescriptions) { PatientsPrescriptions.Add(new DoctorViewModel.Prescription { Date = prescription.Date, ValidSince = prescription.ValidSince, Doctor = await userService.GetUser(Convert.ToInt32(prescription.doctorId)), Id = prescription.prescriptionId }); if (realisedPrescriptions.Select(x => x.prescriptionId).Contains(prescription.prescriptionId)) { PatientsPrescriptions.Last().Realised = true; } else { PatientsPrescriptions.Last().Realised = false; } foreach (var prescriptionMedicine in prescription.medicines) { var medicine = (await medicineModule.SearchMedicineById(prescriptionMedicine.id.ToString())).SingleOrDefault(); if (medicine != null) { PatientsPrescriptions.Last().Medicines.Add(new DoctorViewModel.PrescriptionMedicine(medicine)); PatientsPrescriptions.Last().Medicines.Last().Amount = prescriptionMedicine.amount; } } } OnPropertyChanged("PatientsPrescriptions"); }
public ActionResult Index(string code, string state) { if (ApiHelper.AccessToken == null) { if (ApiHelper.AccessToken == null) { throw new JException("AccessToken无法获取"); } } UserInfo userInfo = Session[WeChatUserInfoKey] as UserInfo; if (userInfo == null) { userInfo = ApiHelper.GetUserInfo(code); Session[WeChatUserInfoKey] = userInfo; //var userdetail = ApiHelper.GetUserDetail(userInfo.UserTicket); } if (userInfo.UserId.IsEmpty()) { Session.Remove(WeChatUserInfoKey); return(null); //throw new JException("微信用户接口失败:" + userInfo.ErrorMessage); } var user = _oauthDataProvider.GetLocalUser(ApiHelper.ProviderName, userInfo.UserId); if (!User.Identity.IsAuthenticated) { if (user == null) { //找不到本地用户则进入账号密码验证页面 return(View()); } else { FormsAuthentication.SetAuthCookie(user.Name, true); } } else { if (user == null) { _oauthDataProvider.SaveOAuthUser(ApiHelper.ProviderName, userInfo.UserId, CurrentUserId.ToInt()); } else if (user.Name != User.Identity.Name) { throw new Exception("用户身份不符"); } } // Session.Remove(WeChatUserInfoKey); if (state.IsEmpty()) { return(Redirect(Url.Content("~/"))); } else { string startPage = Url.Content(_stateUrlService.GetUrl(state)); return(Redirect(Url.Content("~/?startPage=" + Url.Encode(startPage)))); } }