public ActionResult Data(int id) { var tag = _context.Tags.Single(t => t.Id == id); if (tag.TagTypeId == TagTypeConstants.subscriptionType) { var records = new TagDataViewModel { Id = tag.Id, Url = "http://fd-webhost:8080/api/subscriptionTagRecords/" + tag.Id, Name = tag.Name }; return(View("Records", records)); } if (tag.TagTypeId == TagTypeConstants.eventType) { var records = new TagDataViewModel { Id = tag.Id, Url = "http://fd-webhost:8080/api/eventTagRecords/" + tag.Id, Name = tag.Name }; return(View("Records", records)); } return(RedirectToAction("Index", "Tags")); }
public async Task CreateTag(TagDataViewModel tagDataVm) { var tagData = _mapper.Map <TagDataViewModel, Tag>(tagDataVm, options => { options.AfterMap((src, dest) => dest.UserId = _currentUserId); }); await _unitOfWork.Repository <Tag>().AddAsync(tagData); }
public async Task UpdateTag(TagDataViewModel tagData) { var tagToUpdate = await _unitOfWork.Repository <Tag>().FindAsync(x => x.User.Id == _currentUserId); tagToUpdate.TagData = tagData.TagData; tagToUpdate.TagOptions = tagData.TagOptions; tagToUpdate.User = await _userService.GetCurrentUserAsync(); await _unitOfWork.Repository <Tag>().UpdateAsync(tagToUpdate); }
public async Task CreateTag(TagDataViewModel tagData) { var tagModel = new Tag { TagData = tagData.TagData, TagOptions = tagData.TagOptions, User = await _userService.GetCurrentUserAsync() }; await _unitOfWork.Repository <Tag>().AddAsync(tagModel); }
public async Task UpdateTag(TagDataViewModel tagDataVm) { var tag = await _unitOfWork.Repository <Tag>().FindAsync(x => x.UserId == _currentUserId); var tagToUpdate = _mapper.Map(tagDataVm, tag, options => { options.AfterMap((src, dest) => dest.UserId = _currentUserId); }); await _unitOfWork.Repository <Tag>().UpdateAsync(tagToUpdate); }
public async Task <IActionResult> CreateTag([FromBody] TagDataViewModel tagDataVm) { if (_tagService.IsTagExist()) { await _tagService.UpdateTag(tagDataVm); } else { await _tagService.CreateTag(tagDataVm); } return(Ok()); }
public TagDataView() { InitializeComponent(); _vm = root.DataContext as TagDataViewModel; DataObject.AddPastingHandler(txtID, OnPaste); }