Ejemplo n.º 1
0
        public async Task <ResultBM <ManufacturerLogoBM, GetManufacturerLogoExplanation> > GetLogoAsync(ManufacturerIdBM id)
        {
            ManufacturerLogoBM result;

            try {
                var data = await dbContext.Manufacturer.ProjectTo <PManufacturerCompanyLogo>(mapper.ConfigurationProvider).SingleAsync(x => x.Id == id.Value);

                if (data.CompanyLogo == null)
                {
                    return(new FailureResultBM <ManufacturerLogoBM, GetManufacturerLogoExplanation>(GetManufacturerLogoExplanation.ManufacturerLogoNotExists));
                }

                result = new ManufacturerLogoBM(data.CompanyLogo, data.CompanyLogoMimetype);
            }
            catch (InvalidOperationException) {
                return(new FailureResultBM <ManufacturerLogoBM, GetManufacturerLogoExplanation>(GetManufacturerLogoExplanation.ManufacturerNotExists));
            }
            catch (Exception) {
                return(new FailureResultBM <ManufacturerLogoBM, GetManufacturerLogoExplanation>(GetManufacturerLogoExplanation.DatabaseError));
            }

            return(new SuccessfulResultBM <ManufacturerLogoBM, GetManufacturerLogoExplanation>(result));
        }
 public Task <ResultBM <ManufacturerBM, AddManufacturerExplanation> > AddManufacturerAsync(string name, ManufacturerLocationBM location, Uri website = null, ManufacturerLogoBM logo = null)
 {
     ManufacturerBM manufacturer = new ManufacturerBM(
         manufacturerId: default,