Пример #1
0
        public ActionResult Create(User user, bool html = false)
        {
            user.CreatedOn = DateTime.UtcNow;
            var tags = TagsSplitter.Split(db, user.Tags);

            user.UserTags = tags.Select(t => new UserTag {
                User = user, Tag = t
            }).ToList();
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();

                if (html)
                {
                    return(RedirectToAction("Details", new { id = user.UserId }));
                }
                return(Json(new Response {
                    Data = new { user.UserId }
                }));
            }

            if (html)
            {
                return(View(user));
            }
            return(Json(new Response {
                Data = "Failed"
            }));
        }
Пример #2
0
        public ActionResult Create(Request request, bool html = false)
        {
            request.CreatedOn = DateTime.UtcNow;
            var tags = TagsSplitter.Split(db, request.Tags);

            request.RequestTags = tags.Select(t => new RequestTag {
                Request = request, Tag = t
            }).ToList();
            if (ModelState.IsValid)
            {
                db.Requests.Add(request);
                db.SaveChanges();

                if (html)
                {
                    return(RedirectToAction("Details", new { id = request.RequestId }));
                }
                return(Json(new Response {
                    Data = new { request.RequestId }
                }));
            }

            if (html)
            {
                return(View(request));
            }
            return(Json(new Response {
                Data = "Failed"
            }));
        }
        public ActionResult Create(AcceptedRequest acceptedrequest, bool html = false)
        {
            if (ModelState.IsValid)
            {
                db.AcceptedRequests.Add(acceptedrequest);
                db.SaveChanges();

                if (html)
                {
                    return(RedirectToAction("Details", new { id = acceptedrequest.AcceptedRequestId }));
                }
                return(Json(new Response {
                    Data = new { acceptedrequest.AcceptedRequestId }
                }));
            }

            if (html)
            {
                return(View(acceptedrequest));
            }
            return(Json(new Response {
                Data = "Failed"
            }));
        }
Пример #4
0
        public ActionResult Create(Tag tag, bool html = false)
        {
            if (ModelState.IsValid)
            {
                db.Tags.Add(tag);
                db.SaveChanges();

                if (html)
                {
                    return(RedirectToAction("Details", new { id = tag.TagId }));
                }
                return(Json(new Response {
                    Data = new { tag.TagId }
                }));
            }

            if (html)
            {
                return(View(tag));
            }
            return(Json(new Response {
                Data = "Failed"
            }));
        }