Esempio n. 1
0
        public async Task ShowInterestAsync(ShowInterestCommand showInterest)
        {
            var user = await identityService.GetUserAsync();

            await _context.Entry(user).Reference(c => c.Profile).LoadAsync();

            if (user.Profile is ClientProfile)
            {
                var existingInterest = await _context.ClientConsultantInterests
                                       .AnyAsync(c => c.ClientId == user.Profile.Id && c.ConsultantId == showInterest.ConsultantId);

                if (existingInterest)
                {
                    throw new Exception();
                }

                var clientConsultantInterest = mapper.Map <ClientConsultantInterest>(showInterest);
                clientConsultantInterest.Date = DateTime.Now;

                clientConsultantInterest.ClientId = user.ProfileId.GetValueOrDefault();

                _context.ClientConsultantInterests.Add(clientConsultantInterest);
                await _context.SaveChangesAsync();
            }
        }
 public async Task ShowInterest(ShowInterestCommand vm)
 {
     await interestsService.ShowInterestAsync(vm);
 }