public ComplaintViewModel BuildViewModel(Complaint complaint)
 {
     return new ComplaintViewModel() {
         ComplaintText = complaint.ComplaintText,
         DateSubmitted = complaint.DateCreated.ToShortDateString(),
         FacebookUserId = complaint.FacebookUserId,
         FacebookUserName = complaint.FacebookUserName,
         Id = complaint.Id,
         Latitude = complaint.Latitude,
         Longitude = complaint.Longitude,
         Severity = _complaintSeverityBuilder.BuildViewModel(complaint.Severity),
         Tags = complaint.Tags.Select(t => _tagBuilder.BuildViewModel(t)).ToList()
     };
 }
        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);
        }