예제 #1
0
 public ActionResult <TagResource> Create(TagResource resource)
 {
     return(Created(_tagService.Add(resource.ToModel()).Id));
 }
예제 #2
0
        private int CreateTag(TagResource resource)
        {
            var model = resource.ToModel();

            return(_tagService.Add(model).Id);
        }
예제 #3
0
 private Int32 Create(TagResource resource)
 {
     return(_tagService.Add(resource.InjectTo <Tag>()).Id);
 }
예제 #4
0
        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));
 }
예제 #6
0
 private int Create(TagResource resource)
 {
     return(_tagService.Add(resource.ToModel()).Id);
 }
예제 #7
0
 protected internal override T AddIoDevice <T>(T ioDevice)
 {
     _ioDevices.Add(ioDevice);
     _tagService.Add(ioDevice);
     return(ioDevice);
 }
예제 #8
0
 public Task<IResultModel> Add(TagAddModel model)
 {
     return _service.Add(model);
 }
예제 #9
0
        public async Task <ActionResult> Post([FromBody] TagDTO dto)
        {
            var result = await _tagService.Add(dto);

            return(Ok(result));
        }
예제 #10
0
 public void Post([FromBody] TagModel tagModel)
 {
     _tagService.Add(tagModel);
 }
예제 #11
0
        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
                });
            }
        }
예제 #12
0
        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;
            }
        }
예제 #13
0
 public async Task <Result> Add(AddTagDto dto)
 {
     return(await _tagService.Add(_mapper.Map <Tag>(dto)));
 }