Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "kacey"

Just run "update-database" command on the Package Manager Console on visual studio and make sure the EFCore project is selected.

I decided to try out my abilities with Angular 2 by trying to design the SimpleTaskSystem in angular 2. As a novice in angular 2, I am having issues calling the C# GetTasks method in the angular project. There are no samples in angular 2 to guide me on how to do it.

The following AngularJS code is what I am trying to do with angular 2:

$scope.$watch('selectedTaskState', function(value) {
                vm.refreshTasks();
            });

            vm.refreshTasks = function() {
                abp.ui.setBusy( //Set whole page busy until getTasks complete
                    null,
                    taskService.getTasks({ //Call application service method directly from javascript
                        state: $scope.selectedTaskState > 0 ? $scope.selectedTaskState : null
                    }).success(function(data) {
                        vm.tasks = data.tasks;
                    })
                );
            };

What I was trying to do in Angular 2:

@Component({
  //selector: 'app-list',
  templateUrl: './list.component.html',
  animations: [appModuleAnimation()],
  styleUrls: ['./list.component.css']
})
export class ListComponent extends AppComponentBase {

  constructor(injector: Injector, private _taskService: TaskServiceProxy) {
      super(injector);
  }

  tasks: TaskDto[] = [];
  taskInput: GetTaskInput = null;

  ngOnInit() {
      this.getTasks();
  }

  getTasks(): ListOfTaskDto {
      this._taskService.getTasks().subscribe
  }

}

[b]The Method in C#[/b]

public List<TaskDto> GetTasks(GetTaskInput input)
        {
            var tasks = _taskRepository.GetAllWithUsers(input.AssignedUserId, input.State);

            return new List<TaskDto>(tasks.MapTo<List<TaskDto>>());
        }

Having some of the samples already on the website in Angular 2 will go a long way in helping newbies like me intending a quick jump on the technology to take on impending projects. Thanks.

Please I need help with this problem. It's delaying delivery of a proof of concept I'm creating. Please can someone suggest how I can get to the root of this? The data is gotten from the web api but on getting to the client, the error comes up. No message is logged on the console neither is it written to the

log.txt

file.

PLEASE HELP!

Sure.

GoodsRequest Entity

public class GoodsRequest : FullAuditedEntity
    {
        public int CategoryId { get; set; }

        public int CategoryItemId { get; set; }

        public int? BrandId { get; set; }

        public string PreferredBrand { get; set; }

        public int ProductId { get; set; }

        public int Quantity { get; set; }

        [StringLength(10, MinimumLength = 2)]
        public string Unit { get; set; }

        [StringLength(50, MinimumLength = 10)]
        public string PaymentTerm { get; set; }

        public bool ShouldBeDelivered { get; set; }

        [StringLength(150)]
        public string DeliveryLocation { get; set; }

        public long CreatedBy { get; set; }

        [NotMapped]
        public GoodsRequestStatus Status { get; set; }

        [Column("Status")]
        public string StatusString
        {
            get
            {
                return Status.ToString();
            }
            private set
            {
                Status = value.ParseEnum<GoodsRequestStatus>();
            }
        }

        public virtual Category Category { get; set; }

        public virtual CategoryItem CategoryItem { get; set; }

        public virtual Brand Brand { get; set; }

        public virtual Product Product { get; set; }

        public virtual User UserCreator { get; set; }

        public virtual ICollection<GoodsQuote> GoodsQuotes { get; set; }
    }

GoodsRequestDto

[AutoMapFrom(typeof(GoodsRequest))]
    public class GoodsRequestDto : FullAuditedEntityDto
    {
        public int CategoryId { get; set; }

        public int CategoryItemId { get; set; }

        public int? BrandId { get; set; }

        public string PreferredBrand { get; set; }

        public int ProductId { get; set; }

        public int Quantity { get; set; }

        public string Unit { get; set; }

        public string PaymentTerm { get; set; }

        public bool ShouldBeDelivered { get; set; }
        
        public string DeliveryLocation { get; set; }

        public long CreatedBy { get; set; }

        public GoodsRequestStatus Status { get; set; }

        public string StatusString { get; private set; }
        

        public virtual CategoryDto Category { get; set; }

        public virtual CategoryItemDto CategoryItem { get; set; }

        public virtual BrandDto Brand { get; set; }

        public virtual ProductDto Product { get; set; }

        public virtual UserListDto UserCreator { get; set; }

        public virtual ICollection<GoodsQuoteDto> GoodsQuotes { get; set; }
    }

I have a particular method I am calling through angularJS to display some data from the database, but doing so, I get an error that states "An Error has occurred. Error detailed not Sent by the server." I confirmed it by debugging the method and discovered it works just fine and retrieves the data, but when it's time to display on the client, this happens. I have opened the browser console to check what is happening, but the error is not logged there either. If Only I can know what the problem is exactly, it would be so much better. See my code below;

C#

public PagedResultDto<GoodsRequestDto> GetGoodsRequestPaged(GoodsRequestListInput input)
        {
            var goodsRequests = _goodsRequestRepo.GetAllIncluding(g => g.GoodsQuotes)
                .WhereIf(input.UserId.HasValue, g => g.CreatedBy == input.UserId)
                .OrderBy(d => d.Id)
                .PageBy(input)
                .ToList();

            return new PagedResultDto<GoodsRequestDto>
            {
                TotalCount = goodsRequests.Count,
                Items = goodsRequests.MapTo<List<GoodsRequestDto>>()
            };
        }
    }

AngularJS

vm.loadGoodsRequests = function () {
                var skipCount = 0;

                abp.ui.setBusy(null,
                    projectService.getGoodsRequestPaged({
                        skipCount: skipCount,
                        userId: appSession.user.id
                    }).success(function (data) {
                        vm.goodsRequests = data.items;
                    })
                );
            }

HTML

<div ng-if="vm.goodsRequests.length" ng-repeat="gr in vm.goodsRequests" class="classInfo-list-item col-md-6">
            <div class="classInfo-body">
                <h3 class="classInfo-title">
                    {{gr.categoryItem.name + "_" + gr.brand.name + "_" + gr.product.name | cut:true:50:' ...'}}
                </h3>
                <p class="classInfo-description">Quantity: {{gr.quantity}} {{gr.unit}}</p>
                <p class="classInfo-description">Payment Term: {{gr.paymentTerm}}</p>
                <div class="classInfo-registration-info">
                    {{gr.goodsQuotes.length}} Quote(s).
                </div>
                <div class="classInfo-actions">
                    <a class="btn btn-sm btn-info" ng-href="#/my-goods-requests/{{gr.id}}">@L("Details") <i class="fa fa-arrow-circle-right"></i></a>
                </div>
                <span ng-class="vm.statusClass(gr.statusString)" class="classInfo-date"> {{gr.statusString }}</span>
            </div>
        </div>

I used similar approach for other pages of the application and I didn't get any such problem. I don't know what I'm doing wrong and worst of all, I don't know the exact cause of the error.

Please Help! I've been on this for hours. I checked the Logs.txt file, Browser Console no error to describe what the problem is.

How do I disable this? I need the application to be able to start from the default page and can later login to do some specific tasks.

Thanks for your assistance.

I found a solution to it and it's a strange one. Once I made the web project the startup project and tried again, it executed successfully. I don't know why, but it worked.

MVC 5.x with angularJS.

It doesn't exist. I made sure of it. And it's a pretty new project downloaded from the site and I was running it for the first time. I also downloaded another project with a different name entirely and it gave me the same problem.

Showing 1 to 10 of 25 entries