public void AddLinkTest() { /* Initialization */ UserProfile user = testUtil.CreateTestUser(); /* Use case */ long linkId = linkService.AddLink(user.userId, testUtil.TestData.movie1Id, testUtil.TestData.linkName, testUtil.TestData.linkDescription, testUtil.TestData.linkUrl); /* Check */ Link actual = testUtil.FindLink(linkId); testUtil.AssertMatch(actual, linkId, testUtil.TestData.movie1Id, user.userId, testUtil.TestData.linkName, testUtil.TestData.linkDescription, testUtil.TestData.linkUrl, 0); }
protected void BtnAddLink_Click(object sender, EventArgs e) { if (Page.IsValid) { IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ILinkService linkService = container.Resolve <ILinkService>(); ILabelService labelService = container.Resolve <ILabelService>(); UserSession userSession = (UserSession)this.Context.Session["userSession"]; long userId = userSession.UserProfileId; long linkId; try { linkId = linkService.AddLink(userId, MovieId, txtName.Text, txtDescription.Text, txtUrl.Text); } catch (DuplicateInstanceException <LinkDetails> ex) { if (ex.Properties[1].Name == "url") { atvUrl.Visible = true; } else if (ex.Properties[1].Name == "name") { atvName.Visible = true; } return; } labelService.SetLabelsForLink(userId, linkId, new List <string>(txtLabels.Text.Split(' '))); Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Link/Link.aspx?linkId=" + linkId)); } }
public JsonResponse AddLink(Link link) { if (link.OwnerUserID != User.UserData.ID) { return(new JsonResponse(false, "Unauthorized access!")); } var result = _service.AddLink(link); return(new JsonResponse(result)); }
public ActionResult Post([FromBody] ProjectDTO project) { var id = Convert.ToInt32(HttpContext.User.Claims.Where(c => c.Type == "ID").Select(c => c.Value).FirstOrDefault()); if (project != null) { _pserviese.AddProject(project); int pid = _pserviese.GetProjectByTitle(project.title).ProjectId; _lservice.AddLink(new ProjectUserRoleDTO() { UserId = id, ProjectId = pid, RoleId = 1 }); return(Ok(project)); } else { return(BadRequest()); } }
public async Task <IActionResult> Create(LinkModel linkUser) { linkUser.User = await userManager.GetUserAsync(this.User); if (ModelState.IsValid) { linkService.AddLink(linkUser); } else { return(View(linkUser)); } TempData["message"] = "Link added"; return(RedirectToAction("Index", "Home")); }
public IActionResult Shortener(CreateLinkViewModel model) { if (!ModelState.IsValid) { return(JsonFail($"متاسفانه لینک برای کوتاه سازی یافت نشد ...!")); } CreateLinkDto createLinkDto = new CreateLinkDto(model.FullAddress); var result = linkService.AddLink(createLinkDto); if (result.IsSuccess) { return(JsonSuccess(message: result.Message)); } return(JsonFail(message: result.Message)); }
public IActionResult Post([FromBody] Link request) { _service.AddLink(request); return(Ok()); }