Ejemplo n.º 1
0
        public ActionResult Edit(ExampleModel example)
        {
            try
            {
                exampleManager.EditExample(example);
                return(RedirectToAction("Index", new { controller = "Example" }));
            }
            catch (AtomiaServerSideValidationException ex)
            {
                ex.AddModelStateErrors(ModelState, string.Empty);
            }

            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(example));
                }
            }
            catch (Exception e)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(e);
            }

            return(RedirectToAction("Index", new { controller = "Example" }));
        }
Ejemplo n.º 2
0
        public ExampleModel FetchExample(string serviceId)
        {
            try
            {
                return(models[serviceId]);
            }
            catch (Exception ex)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(ex);
            }

            return(new ExampleModel());
        }
Ejemplo n.º 3
0
        public ActionResult Add()
        {
            try
            {
                return(View(new ExampleModel()));
            }
            catch (Exception e)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(e);
            }

            return(RedirectToAction("Index", new { controller = "Example" }));
        }
Ejemplo n.º 4
0
        public List <ExampleModel> FetchObjectsWithPaging(string search, string iDisplayStart, string iDisplayLength, int sortColumn, string sortDirection, out long total)
        {
            var examples = new List <ExampleModel>();

            total = 0;

            try
            {
                var serviceSearchCriteria = new ServiceSearchCriteria[] {
                    new ServiceSearchCriteria {
                        ParentService = null,
                        ServicePath   = exampleServiceData.Path,
                        ServiceName   = exampleServiceData.ServiceName
                    }
                };
                var searchDictionary = search.Length > 0
                    ? new Dictionary <string, string> {
                    { exampleServiceData.ServiceProperties["Name"], "%*" + search + "%*" }
                }
                    : null;
                var exampleServices = coreApi.FindServicesByPathWithPaging(
                    out total,
                    serviceSearchCriteria,
                    searchDictionary,
                    accountId,
                    exampleServiceData.ServiceProperties["Name"],
                    sortDirection.ToLower() == "asc",
                    Convert.ToInt32(iDisplayStart) / Convert.ToInt32(iDisplayLength),
                    Convert.ToInt32(iDisplayLength));

                exampleServices = PackageSelectHelper.FilterServicesToSelectedPackage(controller.RouteData, exampleServices);

                foreach (var exampleService in exampleServices)
                {
                    examples.Add(new ExampleModel {
                        LogicalID = exampleService.logicalId,
                        Name      = GetServicePropertyValue(exampleService, "Name"),
                        Status    = GetServicePropertyValue(exampleService, "Status")
                    });
                }
            }
            catch (Exception ex)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(ex);
                total = 0;
            }

            return(examples);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(string serviceID)
        {
            try
            {
                var serviceId = this.RouteData.Values["serviceID"].ToString();
                var example   = exampleManager.FetchExample(serviceId);

                return(View(example));
            }
            catch (Exception e)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(e);
            }

            return(RedirectToAction("Index", new { controller = "Example" }));
        }
Ejemplo n.º 6
0
        public ExampleModel FetchExample(string serviceId)
        {
            try
            {
                var exampleService = coreApi.GetServiceById(serviceId, accountId);

                return(new ExampleModel
                {
                    LogicalID = exampleService.logicalId,
                    Name = GetServicePropertyValue(exampleService, "Name"),
                    Status = GetServicePropertyValue(exampleService, "Status"),
                });
            }
            catch (Exception ex)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(ex);
            }

            return(new ExampleModel());
        }
Ejemplo n.º 7
0
        public List <ExampleModel> FetchObjectsWithPaging(string search, string iDisplayStart, string iDisplayLength, int sortColumn, string sortDirection, out long total)
        {
            var examples = new List <ExampleModel>();

            total = 0;

            try
            {
                foreach (var example in models.Values)
                {
                    examples.Add(example);
                }

                total = models.Count;
            }
            catch (Exception ex)
            {
                HostingControlPanelLogger.LogHostingControlPanelException(ex);
                total = 0;
            }

            return(examples);
        }