Base solution for your next web application

Activities of "marble68"

TakerController:

using System;
using System.Threading.Tasks;
using Abp.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc;
using okto.work.Web.Areas.App.Models.Takers;
using okto.work.Web.Controllers;
using okto.work.Authorization;
using okto.work.Chat;
using okto.work.Chat.Dtos;
using Abp.Application.Services.Dto;
using Abp.Extensions;
using okto.work.Storage;
using Abp.BackgroundJobs;

namespace okto.work.Web.Areas.App.Controllers
{
    [Area("App")]
    [AbpMvcAuthorize(AppPermissions.Pages_Takers)]
    public class TakersController : TakersControllersBase //workControllerBase
    {
        private readonly ITakersAppService _takersAppService;

        public TakersController(IBinaryObjectManager binaryObjectManager, IBackgroundJobManager backgroundJobManager, ITakersAppService takersAppService)
            : base(binaryObjectManager, backgroundJobManager)
        {
            _takersAppService = takersAppService;
        }

        public ActionResult Index()
        {
            var model = new TakersViewModel
            {
                FilterText = ""
            };

            return View(model);
        }


        [AbpMvcAuthorize(AppPermissions.Pages_Takers_Create, AppPermissions.Pages_Takers_Edit)]
        public async Task<PartialViewResult> CreateOrEditModal(Guid? id)
        {
            GetTakerForEditOutput getTakerForEditOutput;

            if (id.HasValue)
            {
                getTakerForEditOutput = await _takersAppService.GetTakerForEdit(new EntityDto<Guid> { Id = (Guid)id });
            }
            else
            {
                getTakerForEditOutput = new GetTakerForEditOutput
                {
                    Taker = new CreateOrEditTakerDto()
                };
                getTakerForEditOutput.Taker.dateCleared = DateTime.Now;
                getTakerForEditOutput.Taker.dateClearExpires = DateTime.Now;
                getTakerForEditOutput.Taker.dateLastSurvey = DateTime.Now;
            }

            var viewModel = new CreateOrEditTakerModalViewModel()
            {
                Taker = getTakerForEditOutput.Taker,
            };

            return PartialView("_CreateOrEditModal", viewModel);
        }


        public async Task<PartialViewResult> ViewTakerModal(Guid id)
        {
            var getTakerForViewDto = await _takersAppService.GetTakerForView(id);

            var model = new TakerViewModel()
            {
                Taker = getTakerForViewDto.Taker
            };

            return PartialView("_ViewTakerModal", model);
        }


    }
}

Do you want me to email or post here?

Im still getting a 404.

ive tried changing authorization but still 404s.

is there a route or something i have to do to get the method to process?

I updated the TakerController in both MVC and Host.

Using v8.7 Jquery

I'm attempting to provide a way for my users to import an Entity (Taker) with excel.

I'm going through the User Import from excel as an example, along with the ABP documentation here: https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers

I created an ImportTakerDto - providing the exception and CanBeImported method, along with my properties.

I added a custommapper DTO.

I created a class for background job arguments.

I then created a background job, added a new TakersControllerBase. I then modified my TakerController to inherit from the base.

I added the import to excel buttons, and updated the index.js for Takers.

However, I get a 404 when calling it.

I've verified the auth token is there in the request header.

I've run npm run create-bundles on MVC, cleaned and rebuilt the project.

What should I check? Everything builds and runs - the only issue is when it tries to call my ImportFromExcel function on my TakerController it fails.

Thanks for any tips to check.

Was it ever resolved what the problem was here?

For anyone wondering - this in the right place - but I was doing it wrong.

The key is to add rules at the end of the init function, after .validate() is called.

I'm still not sure this is the best place, as I fear my rules will be dumped on an entity regen.

This worked:

         _$takerInformationForm.validate();
            $("#Taker_wasManuallyClearedReason").rules("add", {
                required: function () { return ($("#Taker_isclear").is(':checked') != _TakerClearStatusOnLoad) },
                minlength: 5,
                messages: {
                    required: "Please provide a reason for changing the clear status",
                    minlength: jQuery.validator.format("At least {0} characters are necessary")
                }
            });

I have a checkbox on an entity CreateOrEdit modal, and if it's changed, I need to make one of the inputs required (change the rules).

In the _CreateOrEditModal.js file's init event - I'm doing this:

            _$manualCleared = _modalManager.getModal().find('input[name=wasManuallyCleared]'); // $('#wasManuallyCleared]');
            _$manualCleared.change(function (e) {
                console.log('clear checked');
                console.log(e);
                // if this is set, Taker_wasManuallyClearedReason is required.
                $("#Taker_wasManuallyClearedReason").rules("add", {
                    required: true,
                    minlength: 2,
                    messages: {
                        required: "This field is required",
                        minlength: jQuery.validator.format("More than {0} characters are necessary")
                    }
                })
            });

Thanks for any advice.

Each tenant can create a unit entity called a taker.

Now, the Taker goes to the public website via a unique URL, then enters some info. Once done, I need to update that Taker entity from the public website.

Does disabling filters resolve calling CreateOrEdit? Do I need to impersonate?

Here's what I'm doing. I have this in my Controller for this request:


        [UnitOfWork]
        private void UpdateTaker(CreateOrEditTakerDto input)
        {
           using (var uow = UnitOfWorkManager.Begin())
            {
                using (CurrentUnitOfWork.SetTenantId(null))
                {
                    using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                    {
                        _takersAppService.CreateOrEdit(input).Wait();

                        uow.Complete();
                    }
                }
            }
        }

The error I'm getting is:

AbpAuthorizationException: Current user did not login to the application!

Obviously, the Taker does not log in. How do I do this the "right way". I'm leary of just making a function that can update an entity with no security.

Thanks for any advice.

Ok - I've got this working - part way.

Now, the Taker goes to the public website, enters some info - and I need to update that Taker entity from the public website.

Does disabling filters resolve calling CreateOrEdit?

Here's what I'm doing:

            using (var uow = UnitOfWorkManager.Begin())
            {
                using (CurrentUnitOfWork.SetTenantId(null))
                {
                    using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                    {
                        _takersAppService.CreateOrEdit(input).Wait();

                        uow.Complete();
                    }
                }
            }

The error I'm getting is:

AbpAuthorizationException: Current user did not login to the application!

THanks for any advice.

Showing 211 to 220 of 238 entries