예제 #1
0
        public IActionResult CreateCompany([FromBody] CreateCompanyDto companyDto)
        {
            if (companyDto == null)
            {
                return(BadRequest());
            }

            Company company = Mapper.Map <Company>(companyDto);

            _companiesRepository.AddCompany(company);

            if (!_companiesRepository.Save())
            {
                return(StatusCode(500, "A problem happened with handling you request."));
            }

            return(CreatedAtRoute("GetById", new { id = company.Id }, company));
        }
예제 #2
0
        public async Task <bool> ChangeDescription(ChangeCompanyDescriptionWrite changeComapnyDescription)
        {
            var user = await userRepository.GetByName(UserInfo.UserName);

            var company = companiesRepository.GetBydId(user.Id);

            try
            {
                company.CompanyDescription = changeComapnyDescription.CompanyDescription;
                companiesRepository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public IHttpActionResult Post(Company comp)
 {
     _repository.Insert(comp);
     _repository.Save();
     return(Ok(comp));
 }