Base solution for your next web application

Activities of "vitaly"

Question

Hello, could you help to analyze the issue?

I have the following Task in AppService:

public async Task<StoreDto> CreateOrUpdateStore(CreateOrUpdateStoreInput input)
        {
            if (input.Store.Id.HasValue)
            {
                var store = await _storeRepository.GetAsync(input.Store.Id.Value);
                input.Store.MapTo(store);
                await _storeRepository.UpdateAsync(store);
                return store.MapTo<StoreDto>();
            }
            else
            {
                var store = input.Store.MapTo<Store>();
                await _storeRepository.InsertAsync(store);
                return store.MapTo<StoreDto>();
            }
        }

StoreDto:

[AutoMap(typeof(Store))]
    public class StoreDto
    {
        public int? Id { get; set; }
        ...
        
        //Schedules
        public Collection<StoreScheduleDto> StoreSchedules { get; set; }
    }

StoreScheduleDto:

[AutoMap(typeof(StoreSchedule))]
    public class StoreScheduleDto
    {
        public int? Id { get; set; }
        public int DayOfWeek { get; set; }                  // 0-Every day 1-Mo, 2-Tu, 3-We, 4-Th, 5-Fr, 6-Sa, 7-Su
        public bool Active { get; set; }
        public string StartTime { get; set; }
        public string FinishTime { get; set; }
    }

When I create new Store with collection of StoreSchedules it's working good. But when I try to update existing item, sending to AppService input:

"input": {
        "store": {
            "id": 7,
            "storeGroupId": 1,
            "name": "asdfdf",
            "storeSchedules": [
                {
                    "id": 25,
                    "dayOfWeek": 0,
                    "active": false,
                    "startTime": "09:00",
                    "finishTime": "20:00"
                },
                {
                    "id": 26,
                    "dayOfWeek": 1,
                    "active": true,
                    "startTime": "03:30",
                    "finishTime": "23:30"
                },
               ...

it throw the following error:

System.InvalidOperationException: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted. at System.Data.Entity.Core.Objects.ObjectContext.PrepareToSaveChanges(SaveOptions options) at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesInternalAsync>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Abp.EntityFramework.AbpDbContext.<SaveChangesAsync>d__34.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\AbpDbContext.cs:line 196 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Abp.EntityFramework.Uow.EfUnitOfWork.<SaveChangesInDbContextAsync>d__22.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\EfUnitOfWork.cs:line 198 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at...

Thank you )

Question

Hi,

I would like to repeat same element in html like below. But @L doesn't work properly. The result on the screen is [__Day_0], [__Day_1], etc. I have translation for these words in xml. I guess miss something. How to write it properly?

<div ng-repeat="i in [0,1,2,3,4,5,6,7]" class="row">
                    <div class="col-sm-4">
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="{{'day_'+i}}" class="md-check" type="checkbox" name="{{'day_'+i}}">
                                <label for="{{'day_'+i}}">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("{{'__Day_'+i}}")
                                </label>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-8">
                        <input type="text" id="{{'range_'+i}}" value="" name="range" />
                    </div>
                </div>

Thank you! It helped.

Could you help me?

Hello,

I have problem with integrating ion.RangeSlider plugin in my SPA:

  1. Added to ScriptPaths.cs public const string Ion_RangeSlider = "~/libs/ion-rangeslider/js/ion.rangeSlider.js";

  2. Added to StylePaths.cs public const string Ion_RangeSlider = "~/libs/ion-rangeslider/css/ion.rangeSlider.Metronic.css"; public const string Ion_RangeSlider_Nice = "~/libs/ion-rangeslider/css/ion.rangeSlider.skinNice. public const string Ion_RangeSlider_Norm = "~/libs/ion-rangeslider/css/normalize.css";

  3. Added to AppBundleConfig.cs ScriptPaths.Ion_RangeSlider -> ScriptBundle .Include(StylePaths.Ion_RangeSlider_Norm)->StyleBundle .Include(StylePaths.Ion_RangeSlider)->StyleBundle .Include(StylePaths.Ion_RangeSlider_Nice)->StyleBundle

  4. Added in createOrEditModl.js function ($scope, $uibModalInstance, storeService, storeGroupService, storeId) { var vm = this; var range = $("#range_id"); ... function init() { vm.getStoreForEdit(); vm.getStoreGroups();

             range.ionRangeSlider({});
    
  5. Added in createOrEditModal.cshtml <input type="text" id="range_id" value="" name="range" />

As a result - it doesn't work. On the form I have standard imput field. Please help me)

Is this the same in case (a) Tenant is created manually from Host (b) Tenant is created by user from landing page?

Answer

Ok, i fixed point 2 by myself. But point 1 I can't fix.

Question

**I have 2 questions related to database migration: 1 - I create entities and declare that ID should be called like EntityID, but when the migration script is generated there are two fileds the ID and the EntityID in target Table. See script below, marked in red. Question: why and how to get rid of ID filed?

2 - Two entities are related, I want the relation field to be called the same way in both tables, like EntityID. But when the migration script is generated the field is called Entity_EntityId. See script below, marked green. Question: how and where to override this convention.**

ENTITY #1 [Table("OmniCategories")] public class Category : FullAuditedEntity, IMustHaveTenant { public Category() { Items = new HashSet<Item>(); }

    public virtual int TenantId { get; set; }              

    [Key]
    public virtual int CategoryId { get; set; }             

    public virtual int? ParentCategoryId { get; set; }     

    [ForeignKey("ParentCategoryId")]
    public virtual Category Parent { get; set; }            

    public virtual ICollection&lt;Item&gt; Items { get; set; }    
}

ENTITY #2 [Table("OmniItems")] public class Item : FullAuditedEntity, IMustHaveTenant { public virtual int TenantId { get; set; }

    [Key]
    public virtual int ItemId { get; set; }

    public virtual int? ParentItemId { get; set; }

	[Required]
    [Column("CategoryId")]
    public virtual Category Category { get; set; }

    [ForeignKey("ParentItemId")]
    public virtual Item Parent { get; set; }

}

MIGRATION CreateTable( "dbo.OmniItems", c => new { ItemId = c.Int(nullable: false, identity: true), TenantId = c.Int(nullable: false), ParentItemId = c.Int(), IsDeleted = c.Boolean(nullable: false), DeleterUserId = c.Long(), DeletionTime = c.DateTime(), LastModificationTime = c.DateTime(), LastModifierUserId = c.Long(), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), <span style="color:#FF0000"> Id = c.Int(nullable: false),</span> Category_CategoryId = c.Int(nullable: false),

                },
            annotations: new Dictionary&lt;string, object&gt;
            {
                { "DynamicFilter_Item_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                { "DynamicFilter_Item_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
            })
            .PrimaryKey(t => t.ItemId)
            .ForeignKey("dbo.OmniCategories", t => t.&lt;span style=&quot;color:#00BF00&quot;&gt;Category_CategoryId&lt;/span&gt;, cascadeDelete: true)
            .ForeignKey("dbo.OmniItems", t => t.ParentItemId)
            .Index(t => t.ParentItemId)
            .Index(t => t.Category_CategoryId);

Can I use for User authorization only email, no UserName?

Showing 11 to 20 of 21 entries