Exemplo n.º 1
0
        public ActionResult Networks(string id)
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            centerDetailView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Network_Read");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(centerDetailView));
            }
            #endregion

            GetRequest getRequest = new GetRequest()
            {
                ID = Guid.Parse(id)
            };
            centerDetailView.CenterView = _centerService.GetCenter(getRequest).CenterView;

            GetNetworkCentersRequest req = new GetNetworkCentersRequest()
            {
                CenterID = Guid.Parse(id), NetworkID = Guid.Empty
            };
            centerDetailView.NetworkCenterViews = _networkCenterService.GetNetworkCenters(req).NetworkCenterViews;

            #region DropDownList For Status
            List <DropDownItem> list = new List <DropDownItem>();

            list.Add(new DropDownItem {
                Value = -1, Text = "مشخص نشده"
            });
            list.Add(new DropDownItem {
                Value = 1, Text = "تحت پوشش"
            });
            list.Add(new DropDownItem {
                Value = 2, Text = "عدم پوشش"
            });
            list.Add(new DropDownItem {
                Value = 3, Text = "عدم امکان موقت"
            });

            ViewData["statusData"] = list;

            #endregion

            return(View(centerDetailView));
        }
Exemplo n.º 2
0
        public ActionResult Create(CenterDetailView centerDetailView)
        {
            GeneralResponse response = new GeneralResponse();

            centerDetailView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Center_Insert");
            if (!hasPermission)
            {
                response.ErrorMessages.Add("AccessDenied");
                return(View(centerDetailView));
            }
            #endregion

            if (ModelState.IsValid)
            {
                try
                {
                    AddCenterRequest request = new AddCenterRequest();
                    //request.CreateEmployeeID = GetEmployee().ID;
                    request.CenterName = centerDetailView.CenterView.CenterName;
                    request.Note       = centerDetailView.CenterView.Note;

                    //response = this._centerService.AddCenter(request);

                    if (response.success)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        foreach (string error in response.ErrorMessages)
                        {
                            ModelState.AddModelError("", error);
                        }
                        return(View(centerDetailView));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(centerDetailView));
                }
            }

            return(View(centerDetailView));
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            centerDetailView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Center_Insert");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(centerDetailView));
            }
            #endregion

            return(View(centerDetailView));
        }
Exemplo n.º 4
0
        public ActionResult Status_Read(string id, [DataSourceRequest] DataSourceRequest request)
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            centerDetailView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Center_Read");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                //return Json(centerDetailView.CenterView.NetworkCenters.ToDataSourceResult(request));
                return(Json(false));
            }
            #endregion

            GetRequest getRequest = new GetRequest()
            {
                ID = Guid.Parse(id)
            };
            centerDetailView.CenterView = _centerService.GetCenter(getRequest).CenterView;

            #region DropDownList For Status
            List <DropDownItem> list = new List <DropDownItem>();

            list.Add(new DropDownItem {
                Value = -1, Text = "مشخص نشده"
            });
            list.Add(new DropDownItem {
                Value = 1, Text = "تحت پوشش"
            });
            list.Add(new DropDownItem {
                Value = 2, Text = "عدم پوشش"
            });
            list.Add(new DropDownItem {
                Value = 3, Text = "عدم امکان موقت"
            });

            ViewData["statusData"] = list;
            #endregion

            //return Json(centerDetailView.CenterView.NetworkCenters.ToDataSourceResult(request));
            return(Json(false));
        }
Exemplo n.º 5
0
        public ActionResult Edit(string id)
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            centerDetailView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Center_Update");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(centerDetailView));
            }
            #endregion

            centerDetailView.CenterView = this.GetCenterView(id);

            return(View(centerDetailView));
        }
Exemplo n.º 6
0
        public ActionResult Delete(string id)
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            centerDetailView.EmployeeView = GetEmployee();

            /*
             #region Access Check
             * bool hasPermission = GetEmployee().IsGuaranteed("Center_Delete");
             * if (!hasPermission)
             * {
             *  ModelState.AddModelError("", "AccessDenied");
             *  return View(centerDetailView);
             * }
             #endregion
             */
            centerDetailView.CenterView = this.GetCenterView(id);

            return(View(centerDetailView));
        }
Exemplo n.º 7
0
        public ActionResult Delete(string id, FormCollection collection)
        {
            CenterDetailView centerDetailView = new CenterDetailView();

            /*
             #region Access Check
             * bool hasPermission = GetEmployee().IsGuaranteed("Center_Delete");
             * if (!hasPermission)
             * {
             *  ModelState.AddModelError("", "AccessDenied");
             *  return View(centerDetailView);
             * }
             #endregion
             */
            centerDetailView.CenterView   = this.GetCenterView(id);
            centerDetailView.EmployeeView = GetEmployee();

            DeleteRequest request = new DeleteRequest()
            {
                ID = Guid.Parse(id)
            };

            GeneralResponse response = new GeneralResponse(); //this._centerService.DeleteCenter(request);

            if (response.success)
            {
                return(RedirectToAction("Index"));
            }
            //return Content("F**k");
            else
            {
                foreach (string error in response.ErrorMessages)
                {
                    ModelState.AddModelError("", error);
                }
                return(View(centerDetailView));
            }
        }