コード例 #1
0
        // GET: MeasuredParameterUnits/Delete/5
        public async Task <IActionResult> Delete(int?id,
                                                 string SortOrder,
                                                 string NameKKFilter,
                                                 string NameRUFilter,
                                                 string NameENFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder    = SortOrder;
            ViewBag.PageSize     = PageSize;
            ViewBag.PageNumber   = PageNumber;
            ViewBag.NameKKFilter = NameKKFilter;
            ViewBag.NameRUFilter = NameRUFilter;
            ViewBag.NameENFilter = NameENFilter;
            if (id == null)
            {
                return(NotFound());
            }

            MeasuredParameterUnit measuredParameterUnit = null;
            HttpResponseMessage   response = await _HttpApiClient.GetAsync($"api/MeasuredParameterUnits/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                measuredParameterUnit = await response.Content.ReadAsAsync <MeasuredParameterUnit>();
            }
            if (measuredParameterUnit == null)
            {
                return(NotFound());
            }

            return(View(measuredParameterUnit));
        }
コード例 #2
0
        public async Task <IActionResult> PutMeasuredParameterUnit(int id, MeasuredParameterUnit measuredParameterUnit)
        {
            if (id != measuredParameterUnit.Id)
            {
                return(BadRequest());
            }

            _context.Entry(measuredParameterUnit).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MeasuredParameterUnitExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NameKK,NameRU,NameEN,MPC")] MeasuredParameterUnit measuredParameterUnit,
                                               string SortOrder,
                                               string NameKKFilter,
                                               string NameRUFilter,
                                               string NameENFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder    = SortOrder;
            ViewBag.PageSize     = PageSize;
            ViewBag.PageNumber   = PageNumber;
            ViewBag.NameKKFilter = NameKKFilter;
            ViewBag.NameRUFilter = NameRUFilter;
            ViewBag.NameENFilter = NameENFilter;
            if (id != measuredParameterUnit.Id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync(
                    $"api/MeasuredParameterUnits/{measuredParameterUnit.Id}", measuredParameterUnit);

                string OutputViewText = await response.Content.ReadAsStringAsync();

                OutputViewText = OutputViewText.Replace("<br>", Environment.NewLine);
                try
                {
                    response.EnsureSuccessStatusCode();
                }
                catch
                {
                    dynamic errors = JsonConvert.DeserializeObject <dynamic>(OutputViewText);
                    foreach (Newtonsoft.Json.Linq.JProperty property in errors.Children())
                    {
                        ModelState.AddModelError(property.Name, property.Value[0].ToString());
                    }
                    return(View(measuredParameterUnit));
                }

                measuredParameterUnit = await response.Content.ReadAsAsync <MeasuredParameterUnit>();

                return(RedirectToAction(nameof(Index),
                                        new
                {
                    SortOrder = ViewBag.SortOrder,
                    PageSize = ViewBag.PageSize,
                    PageNumber = ViewBag.PageNumber,
                    NameKKFilter = ViewBag.NameKKFilter,
                    NameRUFilter = ViewBag.NameRUFilter,
                    NameENFilter = ViewBag.NameENFilter
                }));
            }
            return(View(measuredParameterUnit));
        }
コード例 #4
0
        public async Task <ActionResult <MeasuredParameterUnit> > PostMeasuredParameterUnit(MeasuredParameterUnit measuredParameterUnit)
        {
            _context.MeasuredParameterUnit.Add(measuredParameterUnit);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMeasuredParameterUnit", new { id = measuredParameterUnit.Id }, measuredParameterUnit));
        }