示例#1
0
        public ActionResult AddLink(Link link)
        {
            var response = new ResponseWithValidation();

            JsonValidation.GetJsonWithValidation(ModelState, ref response);
            if (ModelState.IsValid)
            {
                Link addedLink = _linkRepository.AddLink(link);
                response.Data = addedLink;
            }
            return(Json(JsonConvert.SerializeObject(response)));
        }
示例#2
0
        public IActionResult Add([FromBody] JObject json)
        {
            string email    = json.GetValue("email").ToString();
            string title    = json.GetValue("title").ToString();
            string url      = json.GetValue("url").ToString();
            string category = json.GetValue("category").ToString();

            try
            {
                ApplicationUser user = _context.Users.Where(u => u.Email == email).FirstOrDefault();
                if (user != null)
                {
                    Link link = new Link()
                    {
                        Title        = title,
                        LinkURL      = url,
                        Date         = DateTime.Now,
                        Rating       = 0,
                        CategoryName = category,
                        UserId       = user.Id,
                    };
                    Link result = _linkRepo.AddLink(link);
                    if (result != null)
                    {
                        return(new JsonResult(new LinkViewModel()
                        {
                            Id = result.Id,
                            Title = result.Title,
                            LinkURL = result.LinkURL,
                            Date = result.Date,
                            Rating = result.Rating,
                            UserName = result.ApplicationUser.CustomUserName != " " ? result.ApplicationUser.CustomUserName : result.ApplicationUser.UserName,
                            UserId = result.ApplicationUser.Id,
                            Category = result.CategoryName
                        }));
                    }
                }
                throw new Exception();
            }
            catch
            {
                return(new NotFoundResult());
            }
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            LinkModel link = new LinkModel();

            link.Title       = txtTitle.Value;
            link.Url         = txtUrl.Value;
            link.ViewOrder   = Convert.ToInt32(txtViewOrder.Value);
            link.Description = txtDescription.Value;

            var repo = new LinkRepository();

            int result = repo.AddLink(link);

            if (result > 0)
            {
                lblError.Text = "저장 완료";
            }
            else
            {
                lblError.Text = "저장되지 않음";
            }
        }
示例#4
0
        public ViewResult Links()
        {
            if (LinkRepository.LinkList.Count == 0)
            {
                Links l1 = new Links {
                    link = "https://en.wikipedia.org/wiki/Master_Chief_(Halo)", title = "Master Chief on Wikipedia"
                };

                Links l2 = new Links {
                    link = "https://www.halowaypoint.com/en-us/universe/characters/master-chief-john-117", title = "Master Chief on Halo Waypoint"
                };

                Links l3 = new Links {
                    link = "https://www.halopedia.org/John-117", title = "Master Chief on Halopedia"
                };

                LinkRepository.AddLink(l1);
                LinkRepository.AddLink(l2);
                LinkRepository.AddLink(l3);
            }
            ViewBag.l = LinkRepository.LinkList;
            return(View("Links", LinkRepository.LinkList));
        }
 public void AddLink(Link link)
 {
     _linkRepository.AddLink(link);
 }
示例#6
0
        public LinkDTO Add(LinkDTO link)
        {
            string user = Membership.GetUser().UserName;

            return(repo.AddLink(link, user));
        }