Ejemplo n.º 1
0
        public async Task <ActionResult> Property_Create([DataSourceRequest] DataSourceRequest request, [FromForm] string models, [FromQuery] Guid siteId)
        {
            // Will keep the inserted entities here. Used to return the result later.
            var properties = string.IsNullOrEmpty(models) ? new List <Property>() : JsonConvert.DeserializeObject <List <Property> >(models);
            var entities   = new List <Property>();

            if (ModelState.IsValid)
            {
                foreach (var property in properties)
                {
                    await _propertyService.CreatePropertyAsync(property);

                    entities.Add(property);
                }
            }

            return(Json(entities.ToDataSourceResult(request, ModelState, property => property)));
        }