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

Activities of "patrickglaudemans"

Hi,

Thanks for thinking with me :-) I'm currently testing a procedure with in I added ReportId property to Entity Job (definition in .core) and change the dto property report into reportId.

I'll update in a sec.

Hi,

public class CreateOrUpdateJobInput : IInputDto { [Required] public JobEditDto Job { get; set; } }

[AutoMapFrom(typeof(Job))] [AutoMapTo(typeof(Job))] public class JobEditDto : FullAuditedEntityDto { public Report Report { get; set; } public string CronSchedule { get; set; } public ReportOutputType OutputType { get; set; } public DateTime? LastRun { get; set; } public bool Active { get; set; } public string Destination { get; set; } }

Hold it - I solved it. Obviously it had something to do with dependencies to other libraries in the project. To begin with the data layer ;-)

pglaudemans

thanks!

Thanks, but can you supply proper link - link is broken!

Thanks! Let me check again. If it keeps on failing I will sent requested code items.

Hi,

contentGroup.Users.Add(new User());

can be ignored - it was for testing p.

Hi,

Thanks for your reply. Last time I provided incomplete code for the example - that's where the null check failed but that is irrelevant. Here is, however, the complete method code. Still the users are not get saved, al other properties like reports, do! THis code is in exact the same appservice structure like recommended in manual etc.

public async Task UpdateContentGroupMembers(UpdateContentGroupMembersInput input)
        {

            if (input != null)
            {
                ContentGroup contentGroup = null;
                if (input.ReportMembers != null)
                {
                    if (input.ReportMembers.Any())
                    {
                        contentGroup = _contentGroupRepository.GetAll()
                            .Include(c=>c.Reports)
                            .Include(c=>c.Users).FirstOrDefault();
                        if (contentGroup != null)
                        {
                            //check if selection is in saved selection - if not add
                            foreach (var selection in input.ReportMembers)
                            {
                                if (contentGroup.Reports.Find(r => r.Id == selection) == null)
                                {
                                    //selected but not yet in saved selection: add
                                    contentGroup.Reports.Add(_reportRepository.Get(selection));
                                }
                            }
                            //check if selection is in saved
                            foreach (var savedSelection in contentGroup.Reports)
                            {
                                if (!input.ReportMembers.Contains(savedSelection.Id))
                                {
                                    //in saved but not selected anymore: delete
                                    contentGroup.Reports.Remove(savedSelection);
                                }
                            }  
                        }
                    }

                    if (input.UserMembers != null)
                    {
                        if (input.UserMembers.Any())
                        {
                            if (contentGroup == null)
                            {
                                contentGroup = _contentGroupRepository.GetAll()
                                    .Include(c => c.Reports)
                                    .Include(c => c.Users).FirstOrDefault();
                            }
                            if (contentGroup != null)
                            {
                                //check if selection is in saved selection - if not add
                                foreach (var selection in input.UserMembers)
                                {
                                    if (contentGroup.Users.Find(r => r.Id == selection) == null)
                                    {
                                        //selected but not yet in saved selection: add
                                        var user = await UserManager.GetUserByIdAsync(System.Convert.ToInt64(selection));
                                        contentGroup.Users.Add(user);
                                    }
                                }
                                //check if selection is in saved
                                foreach (var savedSelection in contentGroup.Users)
                                {
                                    if (!input.UserMembers.Contains(System.Convert.ToInt32(savedSelection.Id)))
                                    {
                                        //in saved but not selected anymore: delete
                                        contentGroup.Users.Remove(savedSelection);
                                    }
                                }

                            }
                        }
                        contentGroup.Users.Add(new User());
                    }
                }

               



                if (contentGroup != null)
                {
                    await _contentGroupRepository.UpdateAsync(contentGroup);    
                }
                else
                {
                    //nothing to do - bye
                }
            }

        }

Best,

My last sentence was not quite clear. What I ment to say is that is has something to do with the user entity not being monitored for changes by the Entity Framework.

Halil any comments? Thanks, Patrick

Showing 21 to 29 of 29 entries