Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] EducationCategory educationCategory)
        {
            if (id != educationCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(educationCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EducationCategoryExists(educationCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(educationCategory));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name")] EducationCategory educationCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(educationCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(educationCategory));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create new navigation property to categories for education
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePostRequestInformation(EducationCategory body, Action <CategoriesRequestBuilderPostRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.POST,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new CategoriesRequestBuilderPostRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }