Exemplo n.º 1
0
        public ActionResult <InternshipMainAttributesViewModel> AddInternship(InternshipAddViewModel internship)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var userID = User.GetUserId();
                if (userID == string.Empty)
                {
                    return(BadRequest("Compania nu a fost recunoscuta"));
                }
                var companyID       = _companyService.GetCompanyIdForUser(userID);
                var addedInternship = _internshipService.AddInternship(InternshipAddMapper.ToInternship(internship, companyID));


                return(Ok(InternshipMapper.ToViewModel(addedInternship)));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }