public IHttpActionResult Post(ConnectionCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateConnectionService();

            if (!service.CreateConnection(model))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
        public ActionResult Create(ConnectionCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!CreateConnectionService().CreateConnection(model))
            {
                ModelState.AddModelError("", "Unable to create connection");
                return(View(model));
            }

            TempData["SaveResult"] = "Your connection was created";

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult Create(ConnectionCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateConnectionService();

            if (service.CreateConnection(model))
            {
                TempData["SaveResult"] = "Your connection was created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your connection could not be created.");
            return(View(model));
        }
        public bool CreateConnection(ConnectionCreateModel model)
        {
            var entity =
                new ConnectionEntity
            {
                UserID         = _userId,
                ConnectionName = model.ConnectionName,
                Job            = model.Job,
                Employer       = model.Employer,
                Phone          = model.Phone,
                Email          = model.Email,
                Notes          = model.Notes,
                EventID        = model.EventID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Connections.Add(entity);

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create()
        {
            var model = new ConnectionCreateModel();

            return(View());
        }