public void Add(Link model) { var entity = LinkFactory.Create(model); _linkRepository.Add(entity); model.Id = entity.Id; }
public LinkModel Add(LinkModel entity) { try { _repo.Add(_mapper.Map <Link>(entity)); UoW.Commit(); return(entity); } catch (Exception) { UoW.RollBack(); return(null); } }
public IActionResult GenerateShortUrl(Link newAd) { if (ModelState.IsValid) { //dodanie użytkownika, który tworzy link (null w przypadku braku) var user = _userManager.GetUserAsync(User); newAd.AdOwner = user.Result; try { _adRepository.Add(newAd); } catch (Exception exception) { return(RedirectToAction("GenerationShortUrlFailure")); } SerializingTools.Put <Link>(TempData, "newAd", newAd); return(RedirectToAction("GenerationShortUrlSuccess")); } return(View(newAd)); }
public async Task <IActionResult> Create([Bind("Id,ShortUrl,RedirectUrl")] Link link) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); link.AdOwner = user; //if user has basic role - clear short url and generate random one if (User.IsInRole("PowerUser") || User.IsInRole("Admin")) { } else { link.ShortUrl = null; } _linkRepository.Add(link); await _linkRepository.SaveChangesAsync(); return(RedirectToAction(nameof(Links))); } return(View(link)); }
public async Task <Unit> Handle(CreateLinkCommand request, CancellationToken cancellationToken) { await _linkRepository.Add(request.ObjectId, request.LinkType, request.Value); return(Unit.Value); }
public void CreateLink(Link link) { linkRepository.Add(link); }
public async Task Add <FileModel>(FileModel entity) { var newEntity = _mapper.Map <Link>(entity); await _repo.Add(newEntity); }
private async void AddLink() { await linkRepository.Add(Link); Done(); }