public async Task <Unit> Handle(CreateWorkshopCommand request, CancellationToken cancellationToken) { var workshop = await _context.AddAsync(new Workshop { EndDate = (DateTime)request.EndDate, SessionId = request.SessionId, StartDate = (DateTime)request.StartDate, WorkshopDescription = request.WorkshopDescription, WorkshopName = request.WorkshopName, WorkshopTypeId = (int)request.WorkshopTypeId, IsOpen = request.IsOpen.Value }); if (request.SeanceCount != null && request.SeanceCount > 0) { DateTime dateIncrement = request.DateTimeFirstSeance.Value; for (int i = 0; i < request.SeanceCount; i++) { workshop.Entity.Seances.Add(new Seance { SeanceDate = dateIncrement, SeanceName = $"Seance {i+1}", SeanceTimeSpan = request.SeanceLenght.Value }); dateIncrement += TimeSpan.FromDays(request.IntervalNbDays.Value); } } await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
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); }
private async Task Log(CancellationToken cancellationToken, TRequest request, string info = null) { var username = _httpContext.HttpContext?.User?.Identity.Name; string userId = null; if (username != null) { if (!_cache.TryGetValue <string>(username, out userId)) { userId = (await _userManager.FindByNameAsync(username)).Id; _cache.CreateEntry(username); _cache.Set <string>(username, userId); } } await _context.AddAsync(new Log { UserId = userId, UserName = username, DateTime = DateTime.Now, CommandName = CommandName(typeof(TRequest)), CommandJSON = JsonConvert.SerializeObject(request), Information = info }); await _context.SaveChangesAsync(cancellationToken); }
public async Task <Unit> Handle(CreateCustomerCommand request, CancellationToken cancellationToken) { int fileNumber = CustomerFileNumberCreator.CreateFileNumberAsync(_context, _time); Customer customer = new Customer { CustomerDescription = new CustomerDescription(), FileNumber = fileNumber, CreationDate = _time.Now, SuppressionDate = null, FirstName = request.Model.FirstName, LastName = request.Model.LastName, NormalizedName = StringNormalizer.Normalize(request.Model.FirstName + request.Model.LastName), DateOfBirth = request.Model.DateOfBirth, Address = request.Model.Address, PostalCode = request.Model.PostalCodeName, City = request.Model.CityName, Province = request.Model.ProvinceName, Country = request.Model.CountryName, Phone = request.Model.Phone, SecondaryPhone = request.Model.SecondaryPhone, SupportGroup = (request.Model.SupportGroupId == null) ? null : _context.SupportGroups.Find(request.Model.SupportGroupId), ReferenceBy = (request.Model.ReferenceById == null) ? null : _context.ReferenceTypes.Find(request.Model.ReferenceById), HeardOfUsFrom = (request.Model.HeardOfUsFromId == null) ? null : _context.HeardOfUsFroms.Find(request.Model.HeardOfUsFromId), InscriptionDate = request.Model.InscriptionDate }; customer.CustomerActivations.Add(new CustomerActivation { IsActive = true, IsActiveSince = DateTime.Now }); _context.Add(customer); await _context.SaveChangesAsync(); return(Unit.Value); }
public async Task <Unit> Handle(UpdateParticipantCommand request, CancellationToken cancellationToken) { var seance = await _context.Seances.FindAsync(request.SeanceId); foreach (var participation in request.ParticipantsAttendance) { var participationEntity = await _context.Participants.FindAsync(participation.ParticipantId); if (participation.ParticipationStatus == Domain.Enums.ParticipationStatus.Absent) { participationEntity.NbHourLate = seance.SeanceTimeSpan; } else if (participation.ParticipationStatus == Domain.Enums.ParticipationStatus.Present) { participationEntity.NbHourLate = new TimeSpan(0, 0, 0); } else { participationEntity.NbHourLate = new TimeSpan(participation.NbHourLate, participation.NbMinuteLate, 0); } participationEntity.Status = participation.ParticipationStatus; await _context.SaveChangesAsync(cancellationToken); } _memory.Remove(InMemoryKeyConstants.PARTICIPANTS_IN_WORKSHOP + request.WorkshopId); return(Unit.Value); }
public async Task <Unit> Handle(CreateProfilOptionCommand <ChildrenAgeBracket> request, CancellationToken cancellationToken) { await _context.AddAsync(new ChildrenAgeBracket { Name = request.Name }); await _context.SaveChangesAsync(); return(Unit.Value); }
public async Task <Unit> Handle(CreateProfilOptionCommand <IncomeSource> request, CancellationToken cancellationToken) { await _context.AddAsync(new IncomeSource { Name = request.Name }); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CreateProfilOptionCommand <Schooling> request, CancellationToken cancellationToken) { await _context.Schoolings.AddAsync(new Schooling { Name = request.Name }); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CreateProfilOptionCommand <CitizenStatus> request, CancellationToken cancellationToken) { await _context.AddAsync(new CitizenStatus { Name = request.Name }); await _context.SaveChangesAsync(); return(Unit.Value); }
public async Task <Unit> Handle(CreateWorkshopTypeCommand request, CancellationToken cancellationToken) { await _context.AddAsync(new WorkshopType { Name = request.Name, Code = request.Code }); await _context.SaveChangesAsync(cancellationToken); _memory.Remove("WorkshopTypeList"); return(Unit.Value); }
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); }
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 <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); }
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 <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 Handle(ParentEspoirDbContext context, CancellationToken cancelationToken) { var option = await context.Set <TProfilOption>().FindAsync(Id); if (option != null) { option.IsDelete = true; await context.SaveChangesAsync(cancelationToken); } }
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); }
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 <VolunteeringType> request, CancellationToken cancellationToken) { var volonteeringType = _context.VolunteeringTypes.Find(request.Id); volonteeringType.Name = request.Name; _context.Update(volonteeringType); await _context.SaveChangesAsync(); return(Unit.Value); }
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(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 <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(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); }
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 <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); }
public async Task <Unit> Handle(CreateProfilOptionCommand <TransportType> request, CancellationToken cancellationToken) { await _context.AddAsync(new TransportType { Name = request.Name, }); 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); }
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); }
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 <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); }