public async Task <IActionResult> Get(long id)
        {
            var companyFromRepo = await _companyLogic.GetByID(id);

            if (companyFromRepo == null)
            {
                return(NotFound());
            }
            var companyToReturn = _mapper.Map <CompanyDetailsDTO>(companyFromRepo);

            return(Ok(companyToReturn));
        }
Example #2
0
        public async Task <IActionResult> ChangePassword(long companyId, [FromBody] CompanyChangePasswordDTO company)
        {
            if (companyId != long.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized("You are not logged in"));
            }

            var companyFromRepo = await _companyLogic.GetByID(companyId);

            if (companyFromRepo.CompanyUsername != User.FindFirst(ClaimTypes.Name).Value)
            {
                return(Unauthorized("You are not logged in"));
            }

            if (!await _companyAuth.ChangePassword(companyFromRepo.CompanyUsername, company.Password))
            {
                return(BadRequest());
            }
            return(Ok());
        }
        public async Task <IActionResult> Post(int mentorId, long companyId, [FromBody] MentorContactToInsertDTO contact)
        {
            if (companyId != long.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var companyFromRepo = _companyLogic.GetByID(companyId);
            var contactToInsert = _mapper.Map <ExternalMentorContact>(contact);

            contactToInsert.ExternalMentorCompanyID = companyId;
            contactToInsert.ExternalMentorMentorID  = mentorId;

            if (!await _logic.Insert(contactToInsert))
            {
                return(BadRequest());
            }
            var contactToReturn = _mapper.Map <ExternalMentorContactDTO>(contactToInsert);

            return(Ok(contactToReturn));
        }