Ejemplo n.º 1
0
        public void CreateCompany(CompanyRequestDTO companyDTO)
        {
            string logoName = "";

            byte[] logoContent = null;

            if (!string.IsNullOrWhiteSpace(companyDTO.LogoFilename))
            {
                logoName    = Path.GetFileName(companyDTO.LogoFilename);
                logoContent = Utility.ConvertImageToByteArray(companyDTO.LogoFilename);
            }
            else
            {
                logoName    = companyDTO.LogoName;
                logoContent = null;
            }
            var obj = new Company()
            {
                Code        = companyDTO.Code,
                Name        = companyDTO.Name,
                LogoName    = logoName,
                LogoContent = logoContent,
                Active      = true,
                Address     = companyDTO.Address,
                Website     = companyDTO.Website,
                Email       = companyDTO.Email,
                Phone       = companyDTO.Phone,

                CreatedBy   = "SYSADMIN",
                CreatedDate = DateTime.Now
            };

            if (!string.IsNullOrWhiteSpace(companyDTO.LogoFilename))
            {
                obj.LogoName    = Path.GetFileName(companyDTO.LogoFilename);
                obj.LogoContent = Utility.ConvertImageToByteArray(companyDTO.LogoFilename);
            }

            _unitOfWork.Company.Create(obj);
            _unitOfWork.SaveChanges();
        }
Ejemplo n.º 2
0
        public void UpdateCompany(CompanyRequestDTO companyDTO)
        {
            var response = _unitOfWork.Company.FindById(companyDTO.ID);

            if (response != null)
            {
                response.Code     = companyDTO.Code;
                response.Name     = companyDTO.Name;
                response.LogoName = companyDTO.LogoName;

                if (!string.IsNullOrWhiteSpace(companyDTO.LogoFilename))
                {
                    response.LogoName    = Path.GetFileName(companyDTO.LogoFilename);
                    response.LogoContent = Utility.ConvertImageToByteArray(companyDTO.LogoFilename);
                }
                response.Address = companyDTO.Address;
                response.Website = companyDTO.Website;
                response.Email   = companyDTO.Email;
                response.Phone   = companyDTO.Phone;
                response.Active  = companyDTO.Active;
            }
            _unitOfWork.Company.Update(response);
            _unitOfWork.SaveChanges();
        }
 public void Put([FromBody] CompanyRequestDTO companyRequestDTO)
 {
     _companyService.UpdateCompany(companyRequestDTO);
 }
 public void Post([FromBody] CompanyRequestDTO companyRequestDTO)
 {
     _companyService.CreateCompany(companyRequestDTO);
 }