2016-04-23 73 views
0

更容易訪問。從下面的代碼中,我一直參考私有IOrderProcessor orderProcessor;來解決此錯誤不一致的可訪問性問題。我已經將私人更改爲公開,但錯誤仍然存​​在。有人可以幫我嗎?不一致的可訪問性:字段類型'FashionWorldApp.Domain.Abstract.IOrderProcessor'比字段'

namespace FashionWorldApp.WebUI.Controllers 
{ 
public class CartController : Controller { 
    private IProductRepository repository; 
    private IOrderProcessor orderProcessor; 

    public CartController(IProductRepository repo, IOrderProcessor proc) 
    { 
     repository = repo; 
     orderProcessor = proc; 
    } 

    public ViewResult Index(Cart cart, string returnUrl) 
    { 
     return View(new CartIndexViewModel 
     { 
      Cart = cart, 
      ReturnUrl = returnUrl 
     }); 
    } 

    public PartialViewResult Summary(Cart cart) 
    { 
     return PartialView(cart); 
    } 

    [HttpPost] 
public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails) 
    { 
     if (cart.Lines.Count() == 0) 
     { 
      ModelState.AddModelError("", "Sorry, your cart is empty!"); 
     } 

     if (ModelState.IsValid) 
     { 
      orderProcessor.ProcessOrder(cart, shippingDetails); 
      cart.Clear(); 
      return View("Completed"); 
     } 
     else 
     { 
      return View(shippingDetails); 
     } 
    } 

    public ViewResult Checkout() 
    { 
     return View(new ShippingDetails()); 
    } 
    public RedirectToRouteResult AddToCart 
      (Cart cart, int productId, string returnUrl) 
    { 
     Product product = repository.Products 
      .FirstOrDefault(p => p.ProductID == productId); 

     if (product != null) 
     { 
      cart.AddItem(product, 1); 
     } 
     return RedirectToAction("Index", new { returnUrl }); 
    } 

public RedirectToRouteResult RemoveFromCart 
     (Cart cart, int productId, string returnUrl) 
    { 
     Product product = repository.Products 
      .FirstOrDefault(p => p.ProductID == productId); 

     if (product != null) 
     { 
      cart.RemoveLine(product); 
     } 
     return RedirectToAction("Index", new { returnUrl }); 
    } 
} 
} 
+0

你可以發佈你的IOrderProcessor的定義。我的直覺是它不是一個公共接口。還有什麼是完整的錯誤? – Arijoon

回答

0

將IProductRepository接口更改爲public。你有一個接受IProductRepository作爲參數的公共構造函數,你需要保證外部調用可以看到它。

+0

謝謝各位回覆。它已被處理。 –

+0

但是,仍然有人可以幫助您創建一個目錄來存儲應用程序中的電子郵件文件 –