Exemplo n.º 1
0
        public ActionResult ContactInfo(ContactInfoView request)
        {
            if (!CurrentUser.IsAuthenticated)
            {
                return(RedirectToAction("Login"));
            }
            request.ContactRegard =
                new KeyValuePair <long, string>(Convert.ToInt64(Request["ContactRegard.Key"]), "");

            /*
             * var school = CurrentUser.Schools()
             *      .FirstOrDefault(d => d.Value == CurrentUser.CurrentSchoolId().ToString(CultureInfo.InvariantCulture));
             *
             * request.School =  new KeyValuePair<long, string>(CurrentUser.CurrentSchoolId(), school != null ? school.Text : "");
             */

            request.School    = new KeyValuePair <long, string>(CurrentUser.CurrentSchoolId(), CurrentUser.Data["SchoolName"].ToString());
            request.UserId    = Convert.ToInt32(CurrentUser.Data["UserId"]);
            request.Email     = CurrentUser.Name;
            request.FirstName = CurrentUser.Data["FirstName"].ToString();
            request.LastName  = CurrentUser.Data["LastName"].ToString();
            var response = SchoolService.CreateContactInfo(new CreateContactInfoRequest {
                ContactInfo = request
            });

            if (response.Result == Result.Success)
            {
                InfoMessage = "Message sent!";
                return(RedirectToAction("ContactInfo"));
            }
            var contactRegards = LookupService.ContactRegards().List.ToList();

            contactRegards.Insert(0, new KeyValuePair <long, string>(0, "Select Regards To"));
            ViewBag.ContactRegards = contactRegards;
            ErrorMessage           = response.Message;
            return(View(request));
        }