public async Task <Unit> Handle(UpdateCustomerCommand request, CancellationToken cancellationToken)
        {
            Customer customer = await _context.Customers
                                .Include(c => c.HeardOfUsFrom)
                                .Include(c => c.SupportGroup)
                                .Include(c => c.ReferenceBy)
                                .SingleOrDefaultAsync(c => c.CustomerId == request.Model.Id);

            customer.FirstName       = request.Model.FirstName;
            customer.LastName        = request.Model.LastName;
            customer.NormalizedName  = StringNormalizer.Normalize(request.Model.FirstName + request.Model.LastName);
            customer.DateOfBirth     = request.Model.DateOfBirth;
            customer.Address         = request.Model.Address;
            customer.PostalCode      = request.Model.PostalCodeName;
            customer.City            = request.Model.CityName;
            customer.Province        = request.Model.ProvinceName;
            customer.Country         = request.Model.CountryName;
            customer.Phone           = request.Model.Phone;
            customer.SecondaryPhone  = request.Model.SecondaryPhone;
            customer.SupportGroup    = (request.Model.SupportGroupId == null) ? null : _context.SupportGroups.Find(request.Model.SupportGroupId);
            customer.ReferenceBy     = (request.Model.ReferenceById == null) ? null : _context.ReferenceTypes.Find(request.Model.ReferenceById);
            customer.HeardOfUsFrom   = (request.Model.HeardOfUsFromId == null) ? null : _context.HeardOfUsFroms.Find(request.Model.HeardOfUsFromId);
            customer.InscriptionDate = request.Model.InscriptionDate;

            _context.Update(customer);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 2
0
        public void GetTest_Success_GetListOfNoneWithDelete()
        {
            Customer customer = CreateCustomer("GetListOfNoneWithOneDelete");

            customer.CustomerActivations.First().IsActive        = false;
            customer.CustomerActivations.First().IsInactiveSince = DateTime.Now;
            customer.IsDelete = true;

            _context.Update(customer);
            _context.SaveChanges();

            var response = _mediator.Send(new GetCustomerListQuery {
                CurrentPage = 1
            }).Result;

            response.ShouldNotBe(null);
            response.ShouldBeOfType(typeof(CustomerListModel));
            response.Customers.Count().ShouldBe(0);
        }
Ejemplo n.º 3
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <Sex> request, CancellationToken cancellationToken)
        {
            var sexToDelete = await _context.Sexs.FindAsync(request.Id);

            sexToDelete.IsDelete = true;
            _context.Update(sexToDelete);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 4
0
        public async Task <Unit> Handle(DeleteVolunteeringCommand request, CancellationToken cancellationToken)
        {
            var volunteering = await _context.Volunteerings.FindAsync(request.VolunteeringId);

            volunteering.IsDelete = true;

            _context.Update(volunteering);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
        public async Task <Unit> Handle(DeleteProfilOptionCommand <MaritalStatus> request, CancellationToken cancellationToken)
        {
            var maritalStatus = await _context.MaritalStatuses.FindAsync(request.Id);

            maritalStatus.IsDelete = true;

            _context.Update(maritalStatus);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 6
0
        public async Task <Unit> Handle(UpdateProfilOptionCommand <SkillToDevelop> request, CancellationToken cancellationToken)
        {
            var skill = await _context.SkillToDevelops.FindAsync(request.Id);

            skill.Name = request.Name;

            _context.Update(skill);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 7
0
        public async Task <Unit> Handle(DeleteDocumentCommand request, CancellationToken cancellationToken)
        {
            var document = await _context.FindAsync <Document>(request.DocumentId);

            document.IsDelete = true;

            _context.Update(document);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 8
0
        public async Task <Unit> Handle(DeleteNoteCommand request, CancellationToken cancellationToken)
        {
            var note = await _context.Notes.FindAsync(request.NoteId);

            note.IsDelete = true;

            _context.Update(note);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 9
0
        public async Task <Unit> Handle(DeleteWorkshopCommand request, CancellationToken cancellationToken)
        {
            var workshop = await _context.Workshops.FindAsync(request.WorkshopId);

            workshop.IsDelete = true;

            _context.Update(workshop);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 10
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <ReferenceType> request, CancellationToken cancellationToken)
        {
            var referenceType = await _context.ReferenceTypes.FindAsync(request.Id);

            referenceType.IsDelete = true;

            _context.Update(referenceType);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <ChildrenAgeBracket> request, CancellationToken cancellationToken)
        {
            var childrenAgeBracked = await _context.FindAsync <ChildrenAgeBracket>(request.Id);

            childrenAgeBracked.Name = request.Name;

            _context.Update(childrenAgeBracked);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <HeardOfUsFrom> request, CancellationToken cancellationToken)
        {
            var heardOfUs = await _context.HeardOfUsFroms.FindAsync(request.Id);

            heardOfUs.Name = request.Name;

            _context.Update(heardOfUs);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 13
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <YearlyIncome> request, CancellationToken cancellationToken)
        {
            var yearlyIncome = await _context.FindAsync <YearlyIncome>(request.Id);

            yearlyIncome.IsDelete = true;

            _context.Update(yearlyIncome);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 14
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <Language> request, CancellationToken cancellationToken)
        {
            var language = await _context.Languages.FindAsync(request.Id);

            language.IsDelete = true;

            _context.Update(language);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <DocumentType> request, CancellationToken cancellationToken)
        {
            var documentType = await _context.DocumentTypes.FindAsync(request.Id);

            documentType.Name = request.Name;

            _context.Update(documentType);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(DeleteProfilOptionCommand <LegalCustody> request, CancellationToken cancellationToken)
        {
            var legalCustodies = await _context.LegalCustodies.FindAsync(request.Id);

            legalCustodies.IsDelete = true;

            _context.Update(legalCustodies);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <Availability> request, CancellationToken cancellationToken)
        {
            var availability = await _context.Set <Availability>().FindAsync(request.Id);

            availability.Name = request.Name;

            _context.Update(availability);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 18
0
        public async Task <Unit> Handle(UpdateProfilOptionCommand <VolunteeringType> request, CancellationToken cancellationToken)
        {
            var volonteeringType = _context.VolunteeringTypes.Find(request.Id);

            volonteeringType.Name = request.Name;

            _context.Update(volonteeringType);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 19
0
        public async Task <Unit> Handle(UpdateProfilOptionCommand <Sex> request, CancellationToken cancellationToken)
        {
            var sex = await _context.FindAsync <Sex>(request.Id);

            sex.Name = request.Name;

            _context.Update(sex);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <IncomeSource> request, CancellationToken cancellationToken)
        {
            var incomeSource = await _context.IncomeSources.FindAsync(request.Id);

            incomeSource.Name = request.Name;

            _context.Update(incomeSource);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 21
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <Schooling> request, CancellationToken cancellationToken)
        {
            var schooling = await _context.Schoolings.FindAsync(request.Id);

            schooling.IsDelete = true;

            _context.Update(schooling);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 22
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <SocialService> request, CancellationToken cancellationToken)
        {
            var socialService = await _context.SocialServices.FindAsync(request.Id);

            socialService.IsDelete = true;

            _context.Update(socialService);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 23
0
        public async Task <Unit> Handle(DeleteProfilOptionCommand <Parent> request, CancellationToken cancellationToken)
        {
            var parent = await _context.Parents.FindAsync(request.Id);

            parent.IsDelete = true;

            _context.Update(parent);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(DeleteProfilOptionCommand <CitizenStatus> request, CancellationToken cancellationToken)
        {
            var citizenStatus = await _context.Set <CitizenStatus>().FindAsync(request.Id);

            citizenStatus.IsDelete = true;

            _context.Update(citizenStatus);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(DeleteSupportGroupCommand request, CancellationToken cancellationToken)
        {
            var supportGroup = await _context.SupportGroups.FindAsync(request.SupportGroupId);

            supportGroup.IsDelete = true;

            _context.Update(supportGroup);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 26
0
        public async Task <Unit> Handle(UpdateProfilOptionCommand <TransportType> request, CancellationToken cancellationToken)
        {
            var transportType = await _context.TransportTypes
                                .Where(t => t.IsDelete == false && t.Id == request.Id)
                                .SingleAsync();

            transportType.Name = request.Name;

            _context.Update(transportType);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
Ejemplo n.º 27
0
        public async Task <Unit> Handle(DeleteSessionCommand request, CancellationToken cancellationToken)
        {
            var session = await _context.Sessions.FindAsync(request.SessionId);

            session.IsDelete = true;

            _context.Update(session);
            await _context.SaveChangesAsync(cancellationToken);

            _memory.Remove("SESSIONLIST");

            return(Unit.Value);
        }
Ejemplo n.º 28
0
        public async Task <Unit> Handle(DeleteWorkshopTypeCommand request, CancellationToken cancellationToken)
        {
            var workshopType = await _context.WorkshopTypes.FindAsync(request.Id);

            workshopType.IsDelete = true;

            _context.Update(workshopType);
            await _context.SaveChangesAsync(cancellationToken);

            _memory.Remove("WorkshopTypeList");

            return(Unit.Value);
        }
Ejemplo n.º 29
0
        public async Task <Unit> Handle(UpdateSupportGroupCommand request, CancellationToken cancellationToken)
        {
            var supportGroup = await _context.SupportGroups.FindAsync(request.SupportGroupId);

            supportGroup.Name        = request.Name;
            supportGroup.Description = request.Description;
            supportGroup.Address     = request.Address;
            supportGroup.UserId      = request.UserId;

            _context.Update(supportGroup);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Ejemplo n.º 30
0
        public async Task <Unit> Handle(DeleteSeanceCommand request, CancellationToken cancellationToken)
        {
            var seance = await _context.Seances.FindAsync(request.SeanceId);

            seance.IsDelete = true;

            _context.Update(seance);
            await _context.SaveChangesAsync(cancellationToken);

            _memory.Remove(InMemoryKeyConstants.SEANCES_IN_WORKSHOP + request.WorkshopId);
            _memory.Remove(InMemoryKeyConstants.GET_SEANCE + request.SeanceId);

            return(Unit.Value);
        }