Beispiel #1
0
        public IActionResult Edit(int id, [Bind("Id,Name,Description,IsEnable")] Company company)
        {
            if (id != company.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ApiConsumer.Put <Company>(company, _options.Value.ApiUrl + $"company/{id}");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyExists(company.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(company));
        }
        public IActionResult Edit(int id, [Bind("Id,Name,Description")] Regulation regulation)
        {
            if (id != regulation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ApiConsumer.Put <List <Regulation> >(regulation, _options.Value.ApiUrl + "regulation/{id}");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegulationExists(regulation.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(regulation));
        }
        public IActionResult Edit(int id,
                                  [Bind("Id,Name,Region,Dns,IpAddress,MetaType,MetaVersion,Description")]
                                  Server server)
        {
            if (id != server.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ApiConsumer.Put <Server>(server, _options.Value.ApiUrl + $"server/{id}");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServerExists(server.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(server));
        }
        public IActionResult Edit(int id, [Bind("Id,Name")] Branch branch)
        {
            if (id != branch.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var response = ApiConsumer.Put <Branch>(branch, _options.Value.ApiUrl + $"branch/{id}");
                    branch = response.Data;
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchExists(branch.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(branch));
        }
        public IActionResult Edit(int id, [Bind("Id,ServerId,RegulationId,BranchId,CompanyId")]
                                  CrossReference crossReference)
        {
            if (id != crossReference.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ApiConsumer.Put <Branch>(crossReference, _options.Value.ApiUrl + $"CrossReference/{id}");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CrossReferenceExists(crossReference.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            var response =
                ApiConsumer.Get <CrossReference>(_options.Value.ApiUrl + $"CrossReference/{id}");

            var server     = ApiConsumer.Get <List <Server> >(_options.Value.ApiUrl + "server");
            var regulation = ApiConsumer.Get <List <Regulation> >(_options.Value.ApiUrl + "regulation");
            var branch     = ApiConsumer.Get <List <Branch> >(_options.Value.ApiUrl + "branch");
            var company    = ApiConsumer.Get <List <Company> >(_options.Value.ApiUrl + "company");

            ViewData["BranchId"]     = new SelectList(branch.Data, "Id", "Name", response.Data.BranchId);
            ViewData["CompanyId"]    = new SelectList(company.Data, "Id", "Name", response.Data.CompanyId);
            ViewData["RegulationId"] = new SelectList(regulation.Data, "Id", "Name", response.Data.RegulationId);
            ViewData["ServerId"]     = new SelectList(server.Data, "Id", "Name", response.Data.ServerId);

            return(View(crossReference));
        }
Beispiel #6
0
        public IActionResult Edit(int id, [Bind("Name,Key,Logins,Id")] Tag tag)
        {
            if (id != tag.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var response =
                        ApiConsumer.Put <Tag>(tag, _options.Value.ApiUrl + "tag/v2");
                }
                catch (DbUpdateConcurrencyException)
                {
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
Beispiel #7
0
        public IActionResult Edit(int id, GroupCrossReferenceViewModel groupCrossReference)
        {
            if (id != groupCrossReference.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var response =
                        ApiConsumer.Get <CrossReference>(
                            _options.Value.ApiUrl + $"CrossReference/{groupCrossReference.CrossReferenceId}");

                    if (response.Data == null)
                    {
                        return(NotFound());
                    }

                    var updatedGcr = new GroupCrossReference
                    {
                        CrossReferenceId = response.Data.Id, GroupName = groupCrossReference.Name, Id = id
                    };

                    ApiConsumer.Put <GroupCrossReference>(updatedGcr, _options.Value.ApiUrl + $"Group/{id}");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupCrossReferenceExists(groupCrossReference.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            var gcr =
                ApiConsumer.Get <GroupCrossReference>(_options.Value.ApiUrl + $"Group/{id}/detail");

            var crossReference = gcr.Data.CrossReference;

            var serverId = crossReference.ServerId;

            var relatedCrossReferences =
                ApiConsumer.Get <List <CrossReference> >(_options.Value.ApiUrl + $"CossReference/Server/{serverId}");

            var selectListDataSource = new List <GroupCrossReferenceViewModel>();

            foreach (var item in relatedCrossReferences.Data)
            {
                selectListDataSource.Add(new GroupCrossReferenceViewModel
                {
                    Id = item.Id,
                    CrossReferenceAlias = item.Server.Name + " - " +
                                          item.Regulation.Name + " - " +
                                          item.Branch.Name + " - " +
                                          item.Company.Name,
                    CrossReferenceId = item.Id
                });
            }

            ViewData["CrossReference"] = new SelectList(selectListDataSource, "CrossReferenceId", "CrossReferenceAlias",
                                                        crossReference.Id);

            var viewModel = new GroupCrossReferenceViewModel
            {
                Id   = gcr.Data.Id,
                Name = gcr.Data.GroupName,
                CrossReferenceAlias = gcr.Data.CrossReference.Server.Name + " - " +
                                      gcr.Data.CrossReference.Regulation.Name + " - " +
                                      gcr.Data.CrossReference.Branch.Name + " - " +
                                      gcr.Data.CrossReference.Company.Name
            };

            return(View(viewModel));
        }