public ActionResult Complain()
 {
     var model = new CreateComplaintViewModel();
     PopulateCreateComplaintModel(model);
     return PartialView("_Complain", model);
 }
        public ActionResult Complain(CreateComplaintViewModel model)
        {
            if (ModelState.IsValid)
            {
                var me = FacebookService.GetMe();

                var complaint = new Complaint()
                {
                    ComplaintText = model.ComplaintText,
                    FacebookUserId = me.FacebookUserId,
                    FacebookUserName = me.Name,
                };

                if (model.SelectedComplaintSeverityId.HasValue)
                {
                    var severity = _complaintSeverityService.Get(model.SelectedComplaintSeverityId.Value);
                    complaint.Severity = severity;
                }

                if (model.TagList.Any())
                {
                    foreach (var tagName in model.TagList)
                    {
                        var tag = _tagService.FindByName(tagName);

                        if (tag == null)
                        {
                            tag = new Tag() {
                                Name = tagName
                            };
                        }

                        complaint.Tags.Add(tag);
                    }
                }

                var errors = _complaintService.Create(complaint);

                if (!errors.Any())
                {
                    if (model.PublishToWall)
                    {
                        FacebookService.Post("feed", new
                        {
                            message = model.ComplaintText,
                            picture = String.Format("{0}/Content/Images/angry smiley.png", Constants.RootUrl),
                            link = String.Format("{0}/Complaint/View/{1}", Constants.RootUrl, complaint.Id),
                            caption = "I just complained",
                            description = "I just posted a complaint on Complainatron",
                            source = String.Format("{0}/Complaint/View/{1}", Constants.RootUrl, complaint.Id),
                        });
                    }

                    var viewModel = _complaintBuilder.BuildViewModel(complaint);
                    return PartialView("_Complaint", viewModel);
                }
                else
                {
                    SetModelStateErrors(errors);
                }
            }

            PopulateCreateComplaintModel(model);
            return PartialView("_Complain", model);
        }
        private void PopulateCreateComplaintModel(CreateComplaintViewModel model)
        {
            var severities = _complaintSeverityService.GetAll();
            var defaultSeverity = severities.Where(s => s.IsDefault).FirstOrDefault();
            var tags = _tagService.GetAll();

            model.Severities = severities.Select(s => new SelectListItem()
            {
                Text = s.Name,
                Selected = s.IsDefault,
                Value = s.Id.ToString()
            });

            model.SelectedComplaintSeverityId = defaultSeverity == null ? (Guid?)null : defaultSeverity.Id;
            model.ExistingTags = tags.Select(t => _tagBuilder.BuildViewModel(t)).ToList();
        }