public async Task <ActionResult> EditCropSort(int id, [FromBody] CropSortDto cropSort)
        {
            if (id != cropSort.Id)
            {
                return(BadRequest("Idler duzgun deyil"));
            }

            var editedCrop = await _context.CropSorts.FirstOrDefaultAsync(s => s.Id == id);

            if (editedCrop == null)
            {
                return(NotFound());
            }

            editedCrop.Crops = await _context.Crops.FirstOrDefaultAsync(s => s.Id == cropSort.CropId);

            foreach (var item in cropSort.ContentForLang)
            {
                var croplang = await _context.CropSortLangs.Include(s => s.CropSort).FirstOrDefaultAsync(s => s.CropSort.Id == cropSort.Id && s.Language.code == item.Languagename);

                croplang.Name = item.Content;
                _context.Entry(croplang).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }

            return(Ok());
        }
        public async Task <ActionResult> GetSort(string lang, int id)
        {
            CropSortDto data = await _context.CropSorts.Where(s => s.Id == id).Select(s => new CropSortDto()
            {
                Id             = s.Id,
                CropId         = s.Crops.Id,
                ContentForLang = s.CropSortLangs.Select(w => new SimpleforDtos.LangcontentDto()
                {
                    Content      = w.Name,
                    Languagename = w.Language.code
                }).ToList()
            }).FirstOrDefaultAsync();

            return(Ok(data));
        }
        public async Task <ActionResult> CreateSort([FromBody] CropSortDto cropSort)
        {
            int id = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var logineduser = await _auth.VerifyUser(id);

            var crop = await _context.Crops.FirstOrDefaultAsync(s => s.Id == cropSort.CropId);

            if (crop == null)
            {
                return(BadRequest("Bele bir mehsul yoxdur"));
            }

            CropSort _newSort = new CropSort()
            {
                Crops   = crop,
                Company = logineduser.Company,
                Status  = true
            };

            _context.CropSorts.Add(_newSort);
            await _context.SaveChangesAsync();

            foreach (var item in cropSort.ContentForLang)
            {
                CropSortLang _sortLang = new CropSortLang()
                {
                    CropSort = _newSort,
                    Language = await _context.Languages.FirstOrDefaultAsync(s => s.code == item.Languagename),
                    Name     = item.Content
                };
                _context.CropSortLangs.Add(_sortLang);
                await _context.SaveChangesAsync();
            }

            return(StatusCode(201));
        }