示例#1
0
        public async Task <IActionResult> PutReceptionRecyclingPoint(int id, ReceptionRecyclingPoint receptionRecyclingPoint)
        {
            if (id != receptionRecyclingPoint.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        // GET: ReceptionRecyclingPoints/Delete/5
        public async Task <IActionResult> Delete(int?id,
                                                 string SortOrder,
                                                 string OrganizationFilter,
                                                 string TypesRawFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder          = SortOrder;
            ViewBag.PageSize           = PageSize;
            ViewBag.PageNumber         = PageNumber;
            ViewBag.OrganizationFilter = OrganizationFilter;
            ViewBag.TypesRawFilter     = TypesRawFilter;
            if (id == null)
            {
                return(NotFound());
            }

            ReceptionRecyclingPoint receptionRecyclingPoint = null;
            HttpResponseMessage     response = await _HttpApiClient.GetAsync($"api/ReceptionRecyclingPoints/{id.ToString()}");

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

            return(View(receptionRecyclingPoint));
        }
        // GET: ReceptionRecyclingPoints/Edit/5
        public async Task <IActionResult> Edit(int?id,
                                               string SortOrder,
                                               string OrganizationFilter,
                                               string TypesRawFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder          = SortOrder;
            ViewBag.PageSize           = PageSize;
            ViewBag.PageNumber         = PageNumber;
            ViewBag.OrganizationFilter = OrganizationFilter;
            ViewBag.TypesRawFilter     = TypesRawFilter;
            ReceptionRecyclingPoint receptionRecyclingPoint = null;
            HttpResponseMessage     response = await _HttpApiClient.GetAsync($"api/ReceptionRecyclingPoints/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                receptionRecyclingPoint = await response.Content.ReadAsAsync <ReceptionRecyclingPoint>();
            }

            List <Project> projects              = new List <Project>();
            string         urlProjects           = "api/Projects",
                           routeProjects         = "";
            HttpResponseMessage responseProjects = await _HttpApiClient.GetAsync(urlProjects + routeProjects);

            if (responseProjects.IsSuccessStatusCode)
            {
                projects = await responseProjects.Content.ReadAsAsync <List <Project> >();
            }
            ViewBag.Projects = new SelectList(projects.OrderBy(m => m.Name), "Id", "Name", receptionRecyclingPoint.ProjectId);

            return(View(receptionRecyclingPoint));
        }
        // GET: ReceptionRecyclingPoints/Create
        public async Task <IActionResult> Create(string SortOrder,
                                                 string OrganizationFilter,
                                                 string TypesRawFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder          = SortOrder;
            ViewBag.PageSize           = PageSize;
            ViewBag.PageNumber         = PageNumber;
            ViewBag.OrganizationFilter = OrganizationFilter;
            ViewBag.TypesRawFilter     = TypesRawFilter;

            List <Project> projects              = new List <Project>();
            string         urlProjects           = "api/Projects",
                           routeProjects         = "";
            HttpResponseMessage responseProjects = await _HttpApiClient.GetAsync(urlProjects + routeProjects);

            if (responseProjects.IsSuccessStatusCode)
            {
                projects = await responseProjects.Content.ReadAsAsync <List <Project> >();
            }
            ViewBag.Projects = new SelectList(projects.OrderBy(m => m.Name), "Id", "Name");

            ReceptionRecyclingPoint model = new ReceptionRecyclingPoint();

            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("Id,Organization,Address,TypesRaw,NorthLatitude,EastLongitude,ProjectId")] ReceptionRecyclingPoint receptionRecyclingPoint,
                                                 string SortOrder,
                                                 string OrganizationFilter,
                                                 string TypesRawFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder          = SortOrder;
            ViewBag.PageSize           = PageSize;
            ViewBag.PageNumber         = PageNumber;
            ViewBag.OrganizationFilter = OrganizationFilter;
            ViewBag.TypesRawFilter     = TypesRawFilter;
            if (ModelState.IsValid)
            {
                HttpResponseMessage response = await _HttpApiClient.PostAsJsonAsync(
                    "api/ReceptionRecyclingPoints", receptionRecyclingPoint);

                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(receptionRecyclingPoint));
                }

                return(RedirectToAction(nameof(Index),
                                        new
                {
                    SortOrder = ViewBag.SortOrder,
                    PageSize = ViewBag.PageSize,
                    PageNumber = ViewBag.PageNumber,
                    OrganizationFilter = ViewBag.OrganizationFilter,
                    TypesRawFilter = ViewBag.TypesRawFilter
                }));
            }

            List <Project> projects              = new List <Project>();
            string         urlProjects           = "api/Projects",
                           routeProjects         = "";
            HttpResponseMessage responseProjects = await _HttpApiClient.GetAsync(urlProjects + routeProjects);

            if (responseProjects.IsSuccessStatusCode)
            {
                projects = await responseProjects.Content.ReadAsAsync <List <Project> >();
            }
            ViewBag.Projects = new SelectList(projects.OrderBy(m => m.Name), "Id", "Name", receptionRecyclingPoint.ProjectId);

            return(View(receptionRecyclingPoint));
        }
示例#6
0
        public async Task <ActionResult <ReceptionRecyclingPoint> > PostReceptionRecyclingPoint(ReceptionRecyclingPoint receptionRecyclingPoint)
        {
            _context.ReceptionRecyclingPoint.Add(receptionRecyclingPoint);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetReceptionRecyclingPoint", new { id = receptionRecyclingPoint.Id }, receptionRecyclingPoint));
        }