public ActionResult <TagResource> Create(TagResource resource) { return(Created(_tagService.Add(resource.ToModel()).Id)); }
private int CreateTag(TagResource resource) { var model = resource.ToModel(); return(_tagService.Add(model).Id); }
private Int32 Create(TagResource resource) { return(_tagService.Add(resource.InjectTo <Tag>()).Id); }
public async Task <IActionResult> onPost(Tag tag) { Tag created = await _tagsService.Add(tag); return(CreatedAtRoute("GetTag", new { Id = created.Id }, created)); }
public async Task <Tag> Add() { return(await _service.Add(Rec, UserInfo.UserId)); }
private int Create(TagResource resource) { return(_tagService.Add(resource.ToModel()).Id); }
protected internal override T AddIoDevice <T>(T ioDevice) { _ioDevices.Add(ioDevice); _tagService.Add(ioDevice); return(ioDevice); }
public Task<IResultModel> Add(TagAddModel model) { return _service.Add(model); }
public async Task <ActionResult> Post([FromBody] TagDTO dto) { var result = await _tagService.Add(dto); return(Ok(result)); }
public void Post([FromBody] TagModel tagModel) { _tagService.Add(tagModel); }
public static async Task SeedData(UserManager <AppUser> userManager, RoleManager <AppRole> roleManager, IKategoriService kategoriService, ITagService tagService) { var adminRole = await roleManager.FindByNameAsync(RoleNames.Admin.ToString()); if (adminRole == null) { await roleManager.CreateAsync(new AppRole { Name = RoleNames.Admin.ToString() }); } var memberRole = await roleManager.FindByNameAsync(RoleNames.Member.ToString()); if (memberRole == null) { await roleManager.CreateAsync(new AppRole { Name = RoleNames.Member.ToString() }); } var modRole = await roleManager.FindByNameAsync(RoleNames.Moderator.ToString()); if (modRole == null) { await roleManager.CreateAsync(new AppRole { Name = RoleNames.Moderator.ToString() }); } var valRole = await roleManager.FindByNameAsync(RoleNames.Validator.ToString()); if (valRole == null) { await roleManager.CreateAsync(new AppRole { Name = RoleNames.Validator.ToString() }); } var wriRole = await roleManager.FindByNameAsync(RoleNames.Writer.ToString()); if (wriRole == null) { await roleManager.CreateAsync(new AppRole { Name = RoleNames.Writer.ToString() }); } var adminUser = await userManager.FindByNameAsync("mustafa"); if (adminUser == null) { AppUser user = new AppUser { UserName = "******", Email = "*****@*****.**" }; await userManager.CreateAsync(user, "mustafa"); await userManager.AddToRoleAsync(user, RoleNames.Admin.ToString()); } var kategoriler = kategoriService.GetAll(); if (kategoriler.Result.Count < 1) { await kategoriService.Add(new Kategori() { KategoriIsmi = "Hakkımda" }); await kategoriService.Add(new Kategori() { KategoriIsmi = "İletisim" }); await kategoriService.Add(new Kategori() { KategoriIsmi = "Karalamalar" }); } var tagler = tagService.GetAll(); if (tagler.Result.Count < 1) { await tagService.Add(new Tag() { TagName = "Duygusal", //AppUser = userManager.FindByNameAsync("mustafa").Result, AppUserId = userManager.FindByNameAsync("mustafa").Result.Id });; await tagService.Add(new Tag() { //AppUser = userManager.FindByNameAsync("mustafa").Result, TagName = "Yenilikçi", AppUserId = userManager.FindByNameAsync("mustafa").Result.Id }); await tagService.Add(new Tag() { //AppUser = userManager.FindByNameAsync("mustafa").Result, TagName = "İşe yarar", AppUserId = userManager.FindByNameAsync("mustafa").Result.Id }); } }
public IActionResult SaveEntity(TagViewModel tagVm) { try { var productTag = CommonConstants.ProductTag; if (!_tagService.IsTagNameExists(tagVm.Name)) { if (_tagService.ValidateAddTagName(tagVm, productTag)) { ModelState.AddModelError("", "Tên tag đã tồn tại"); } if (_tagService.ValidateAddTagOrder(tagVm, productTag)) { ModelState.AddModelError("", "Thứ tự đã tồn tại"); } if (!ModelState.IsValid) { return(BadRequest(ModelState.Select(x => x.Value.Errors).FirstOrDefault(y => y.Count > 0)?.First() .ErrorMessage)); } _tagService.Add(tagVm, productTag); } else { if (_tagService.ValidateUpdateTagName(tagVm, productTag)) { ModelState.AddModelError("", "Tên tag đã tồn tại"); } if (_tagService.ValidateUpdateTagOrder(tagVm, productTag)) { ModelState.AddModelError("", "Thứ tự đã tồn tại"); } if (!ModelState.IsValid) { return(BadRequest(ModelState.Select(x => x.Value.Errors).FirstOrDefault(y => y.Count > 0)?.First() .ErrorMessage)); } _tagService.Update(tagVm); } //if (!ModelState.IsValid) //{ // IEnumerable<ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); // return new BadRequestObjectResult(allErrors); //} _tagService.Save(); return(new OkObjectResult(tagVm)); } catch (Exception ex) { throw ex; } }
public async Task <Result> Add(AddTagDto dto) { return(await _tagService.Add(_mapper.Map <Tag>(dto))); }