Example #1
0
 public async Task<OperationResult<Supplier>> EditSupplier(Supplier supplier)
 {
     try
     {
         await _supplierRepository.Edit(supplier);
         return new OperationResult<Supplier>(true) { Entity = supplier };
     }
     catch 
     {
         return new OperationResult<Supplier>(false);
     }
 }
        public static Supplier ToSupplier(this SupplierRequestModel requestModel)
        {
            var supplier = new Supplier()
            {
                CompanyName = requestModel.CompanyName,
                ContactName = requestModel.ContactName,
                ContactTitle = requestModel.ContactTitle,
                Address = requestModel.Address,
                City = requestModel.City,
                Region = requestModel.Region,
                PostalCode = requestModel.PostalCode,
                Country = requestModel.Country,
                Phone = requestModel.Phone,
                Fax = requestModel.Fax,
                HomePage = requestModel.HomePage
            };

            if (requestModel.SupplierID.HasValue)
                supplier.SupplierID = requestModel.SupplierID.Value;

            return supplier;
        }