public ActionResult CreateFromServiceId(StudentWidget studentwidget)
        {
            var widget = new StudentWidget();

            try{
                using (var svc = new WebserviceFundAFSerSoapClient())
                {
                    XElement studentAccount = svc.AFSWidgetGetProgramDetails("afserwidget", "globalwidgerasfer2012",
                                                                             studentwidget.ServiceId.ToString());

                    Guid serviceId;
                    DateTime endDate;

                    if (studentAccount.Descendants("GLMessage").First().Value.Equals("Success"))
                    {
                        bool isValidAcct = Guid.TryParse(studentAccount.Descendants("Service_ID").First().Value, out serviceId);
                        if (!isValidAcct)
                        {
                            TempData["WSError"] = "Not a valid Service Id.";
                            return RedirectToAction("Index");
                        }
                        widget.ServiceId = Guid.Parse(studentAccount.Descendants("Service_ID").First().Value);
                        widget.FirstName = studentAccount.Descendants("First_Name").First().Value;
                        widget.LastName = studentAccount.Descendants("Last_Name").First().Value;
                        widget.State = studentAccount.Descendants("State").First().Value;
                        widget.ProgramRefCode = studentAccount.Descendants("Program_Code").First().Value;
                        widget.DestinationCountry = studentAccount.Descendants("Hosting_Country").First().Value;
                        widget.Srn = studentAccount.Descendants("Service_Ref").First().Value;
                        widget.AreaTeam = studentAccount.Descendants("Area_Team_Name").First().Value;
                        widget.State = studentAccount.Descendants("State").First().Value;
                        widget.EnabledStatus = 1;
                        widget.DisplayName = widget.FirstName + ' ' + widget.LastName;
                        widget.EndDate = DateTime.TryParse(studentAccount.Descendants("Widget_End_Date").First().Value, out endDate) ? endDate : DateTime.Now.AddMonths(3);
                        widget.FundraisingAmount = decimal.Parse(studentAccount.Descendants("Widget_Amount").First().Value);

                        return View(widget);
                    }
                    //If we get here and didn't hit the View or an Error, then it is a bad Id.

                }
            }
            catch(Exception e)
            {
                TempData["WSError"] = "Error in Global Link response: " + e.Message;
            }

            return RedirectToAction("Index");
        }
        public ActionResult Create(StudentWidget studentwidget)
        {
            if (ModelState.IsValid)
            {
                studentwidget.StudentWidgetId = Guid.NewGuid();
                _db.StudentWidgets.Add(studentwidget);
                using (var svc = new WebserviceFundAFSerSoapClient())
                {
                    var reply = svc.AFSWidgetSetCode("afserwidget", "globalwidgerasfer2012",
                                         studentwidget.ServiceId.ToString(),
                                         studentwidget.StudentWidgetId.ToString(),
                                         "http://donatew.afsusa.org/SponsorAnAFSer/Widget/Details/" + studentwidget.StudentWidgetId.ToString(),
                                         studentwidget.EndDate.ToString());
                }
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            return RedirectToAction("Index");
        }
        public ActionResult Edit(StudentWidget studentwidget)
        {
            var widget = new StudentWidget();
            try
            {
                if (ModelState.IsValid)
                {
                    widget = _db.StudentWidgets.Find(studentwidget.StudentWidgetId);
                    widget.FundraisingAmount = studentwidget.FundraisingAmount;
                    widget.EndDate = studentwidget.EndDate;
                    widget.BlogUrl = studentwidget.BlogUrl;
                    widget.DestinationCountry = studentwidget.DestinationCountry;
                    widget.EnabledStatus = studentwidget.EnabledStatus;
                    widget.DisplayName = studentwidget.DisplayName;

                    _db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (DataException e)
            {
                Console.WriteLine(e);
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                return View(widget);
            }
            return RedirectToAction("Index");
        }