示例#1
0
        public IActionResult OnPostLoadWard([FromBody] Ward model)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestResult());
            }

            var ward = _wardRepository.GetSome(cd => cd.DistrictId == model.DistrictId);

            if (ward != null)
            {
                Wards = new List <Ward>();
                var items = ward.Where(cd => cd.IsDeleted == false).ToList();
                if (items.Count > 0)
                {
                    foreach (var item in items)
                    {
                        var wards = new Ward
                        {
                            Id           = item.Id,
                            Name         = item.Name,
                            Type         = item.Type,
                            SortOrder    = item.SortOrder,
                            LatiLongTude = item.LatiLongTude,
                            DistrictId   = item.DistrictId,
                            IsPublished  = item.IsPublished,
                            IsDeleted    = item.IsDeleted,
                            Timestamp    = item.Timestamp,
                        };
                        Wards.Add(wards);
                    }
                }
            }
            return(new OkObjectResult(Wards));
        }