Ejemplo n.º 1
0
        public JsonResult GetPCMethod()
        {
            List <PCMethodsModel>      model  = PCMethodServiceManager.GetPCMethodList().OrderBy(e => e.Name).ToList();
            List <PCMethodOutputModel> output = new List <PCMethodOutputModel>();

            foreach (PCMethodsModel item in model)
            {
                PCMethodOutputModel newModel = new PCMethodOutputModel()
                {
                    Id   = item.Id,
                    Name = item.Name
                };

                output.Add(newModel);
            }

            return(Json(output));
        }
Ejemplo n.º 2
0
        public ActionResult Modify(string id)
        {
            if (Request.Browser.IsMobileDevice)
            {
                return(RedirectToAction("ModifyM"));
            }

            ObservesModel              model          = ObserveServiceManager.GetObserveById(id);
            List <StepsModel>          oriList        = StepServiceManager.GetStepListByObserveId(id);
            List <PCMethodsModel>      methodList     = PCMethodServiceManager.GetPCMethodList().OrderBy(e => e.Name).ToList();
            List <StepListOutputModel> newList        = new List <StepListOutputModel>();
            List <PCMethodOutputModel> PCMethodOutput = new List <PCMethodOutputModel>();

            foreach (StepsModel item in oriList)
            {
                string StringMethod    = null;
                string StringSetHeader = null;

                if (item.Method == 1)
                {
                    StringMethod = "GET";
                }
                else if (item.Method >= 2)
                {
                    StringMethod = "POST";
                }

                if (item.SetHeader == 1)
                {
                    StringSetHeader = "Yes";
                }
                else if (item.SetHeader == 0)
                {
                    StringSetHeader = "No";
                }
                else if (item.SetHeader == 2)
                {
                    StringSetHeader = "Pre";
                }
                StepListOutputModel newModel = new StepListOutputModel()
                {
                    Id        = item.Id,
                    Priority  = item.Order.GetValueOrDefault(),
                    Url       = item.Url,
                    Method    = StringMethod,
                    SetHeader = StringSetHeader
                };
                newList.Add(newModel);
            }

            foreach (PCMethodsModel item in methodList)
            {
                PCMethodOutputModel newModel = new PCMethodOutputModel()
                {
                    Id   = item.Id,
                    Name = item.Name
                };

                PCMethodOutput.Add(newModel);
            }

            try
            {
                ObserveOutputModel output = new ObserveOutputModel()
                {
                    Id       = model.Id,
                    Name     = model.Name,
                    Status   = model.Status.GetValueOrDefault(),
                    Interval = model.Interval.GetValueOrDefault(),
                    StepList = newList,
                    PCMethod = PCMethodOutput
                };

                return(View(output));
            } catch (NullReferenceException e)
            {
                return(RedirectToAction("Index", "Observe"));
            }
        }