Example #1
0
        public async Task <ConsultantProfileDto> CreateConsultantProfileAsync(AddConsultantProfileDto dto)
        {
            var consultantProfile = mapper.Map <ConsultantProfile>(dto);

            if (consultantProfile.AvailableFromDate != null)
            {
                consultantProfile.AvailableFromDate = consultantProfile.AvailableFromDate?.Date;
            }

            var user = await identityService.GetUserAsync();

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

            if (dto.OrganizationId == null)
            {
                consultantProfile.OrganizationId = user.Profile.OrganizationId;
            }

            _context.ConsultantProfiles.Add(consultantProfile);
            await _context.SaveChangesAsync();

            return(mapper.Map <ConsultantProfileDto>(consultantProfile));
        }
        public async Task <ActionResult <ConsultantProfileDto> > CreateConsultantProfile(AddConsultantProfileDto dto)
        {
            try
            {
                var consultantProfile = await consultantManager.CreateConsultantProfileAsync(dto);

                return(CreatedAtAction("GetConsultantProfile", new { id = consultantProfile.Id }, consultantProfile));
            }
            catch (NotFoundException exc)
            {
                return(Problem(exc.Message, statusCode: StatusCodes.Status404NotFound));
            }
        }