public int Post([FromBody] CompanyEntity company)
        {
            try
            {
                //var CompanyLogo = HttpContext.Current.Request.Files["CompanyLogo"];
                //var data = HttpContext.Current.Request.Form["data"];

                //var company = JsonConvert.DeserializeObject<CompanyEntity>(data);

                //string path = HttpContext.Current.Server.MapPath("~/UploadedDocuments");
                //bool folderExists = Directory.Exists(path);
                //if (!folderExists)
                //    Directory.CreateDirectory(path);

                //var fileName = DateTime.Now.Ticks + Path.GetExtension(CompanyLogo.FileName);

                //var fileSavePath = Path.Combine(path, fileName);
                //CompanyLogo.SaveAs(fileSavePath);

                //if (File.Exists(fileSavePath))
                //{
                //    company.CompanyLogo = fileName;
                //}
                //else
                //{
                //    return -1;
                //}
                return(_companyServices.CreateCompany(company));
            }
            catch (Exception ex)
            {
                throw new ApiDataException(1000, "Company Not Found", HttpStatusCode.NotFound);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> PostCompany(CompanyDto companyDto)
        {
            try
            {
                var company = _mapper.Map <Company>(companyDto);
                company.IsActive = true;
                await _repo.CreateCompany(company);

                return(Ok("Company Was Registred!"));
            }
            catch (Exception e)
            {
                return(Ok(e.Message));
            }
        }