2012-05-10 6 views
0

J'ai ce simple morceau de codage dans mon Homecontroller.cs, mais je reçois le message d'erreur sur la dernière ligne, en disant "Le nom 'modToSend' n'est pas exister dans le contexte actuel ". Comment est-ce possible? Seulement dans la dernière ligne est-il inconnu ????"Le nom 'modToSend' n'existe pas dans le contexte actuel"

public class HomeController : Controller, IDisposable 
{ 
    private MvcEShop2.WcfEshop2Service.Eshop2ServiceClient proxy = null; 

    private String GetDuration(DateTime startdatum, DateTime einddatum) 
    { 
     String maand1 = startdatum.Month.ToString("MMMM"); 
     String maand2 = einddatum.Month.ToString("MMMM"); 
     String duration = ""; 
     if (maand1 == maand2) 
     { 
      duration = startdatum.Day.ToString() 
       + " - " + einddatum.Day.ToString() 
       + " " + maand1 
       + " " + startdatum.Year.ToString(); 
     } 
     else 
     { 
      duration = startdatum.Day.ToString() 
       + startdatum.Month.ToString("MMMM") 
       + " - " + einddatum.Day.ToString() 
       + " " + einddatum.Month.ToString("MMMM") 
       + " " + startdatum.Year.ToString(); 
     } 
     return duration; 
    } 


    public HomeController() 
    { 
     proxy = new MvcEShop2.WcfEshop2Service.Eshop2ServiceClient(); 
    } 

    struct EventStruct 
    { 
     public SEvent Event { get; set; } 
     public String Duration { get; set; } 
    }; 

    public ActionResult Index() 
    { 
     List<SEvent> modFromWcf = proxy.GetAllEventsByPeriod(@System.DateTime.Now.Year, @System.DateTime.Now.Year + 1, "EN").ToList(); 
     List<EventStruct> modTosend = new List<EventStruct>(); 
     foreach (SEvent item in modFromWcf) 
     { 
      EventStruct ES; 
      ES.Event = item; 
      ES.Duration = GetDuration(item.StartDate ,item.EndDate); 
      modTosend.Add(ES); 
     }; 

     return View("Index", modToSend); 
    } 
} 

Répondre

2

Si c'est une pâte copie directe & à partir de votre code, vérifiez le cas du « S » dans votre paramètre à la vue du renvoi.

Questions connexes