Пример #1
0
        public ActionResult Create(WebsiteModel model)
        {
            if (ModelState.IsValid)
            {
                try {
                    if (!Regex.Match(model.Url.ToLowerInvariant(), "^http[s]?://").Success)
                    {
                        model.Url = String.Format("http://{0}", model.Url);
                    }

                    websiteService.AddWebsite(model.ContactId, model.ToEntity());
                    return(RedirectToAction("Index", new { id = model.ContactId }));
                } catch (Exception ex) {
                    ViewBag.ErrorMessage = ex.Message;
                    return(View(model));
                }
            }

            return(View(model));
        }