Beispiel #1
0
        public ActionResult Post(bool IsNew, Spartan_BR_TestingModel varSpartan_BR_Testing)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _ISpartan_BR_TestingApiConsumer.SetAuthHeader(_tokenManager.Token);


                    if (varSpartan_BR_Testing.EvidenceRemoveAttachment != 0 && varSpartan_BR_Testing.EvidenceFile == null)
                    {
                        varSpartan_BR_Testing.Evidence = 0;
                    }

                    if (varSpartan_BR_Testing.EvidenceFile != null)
                    {
                        var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varSpartan_BR_Testing.EvidenceFile);
                        _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                        varSpartan_BR_Testing.Evidence = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File()
                        {
                            File        = fileAsBytes,
                            Description = varSpartan_BR_Testing.EvidenceFile.FileName,
                            File_Size   = fileAsBytes.Length
                        }).Resource;
                    }


                    var result = "";
                    var Spartan_BR_TestingInfo = new Spartan_BR_Testing
                    {
                        Key_Testing          = varSpartan_BR_Testing.Key_Testing
                        , User_that_reviewed = varSpartan_BR_Testing.User_that_reviewed
                        , Acceptance_Critera = varSpartan_BR_Testing.Acceptance_Critera
                        , It_worked          = varSpartan_BR_Testing.It_worked
                        , Rejection_Reason   = varSpartan_BR_Testing.Rejection_Reason
                        , Comments           = varSpartan_BR_Testing.Comments
                        , Evidence           = (varSpartan_BR_Testing.Evidence.HasValue && varSpartan_BR_Testing.Evidence != 0) ? ((int?)Convert.ToInt32(varSpartan_BR_Testing.Evidence.Value)) : null
                    };

                    result = !IsNew?
                             _ISpartan_BR_TestingApiConsumer.Update(Spartan_BR_TestingInfo, null, null).Resource.ToString() :
                                 _ISpartan_BR_TestingApiConsumer.Insert(Spartan_BR_TestingInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 35348);

            ViewBag.Permission = permission;
            var varSpartan_BR_Testing = new Spartan_BR_TestingModel();

            ViewBag.ObjectId  = "35348";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_TestingApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_BR_TestingData = _ISpartan_BR_TestingApiConsumer.GetByKeyComplete(Id).Resource.Spartan_BR_Testings[0];
                if (Spartan_BR_TestingData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_BR_Testing = new Spartan_BR_TestingModel
                {
                    Key_Testing                   = (int)Spartan_BR_TestingData.Key_Testing
                    , User_that_reviewed          = Spartan_BR_TestingData.User_that_reviewed
                    , User_that_reviewedName      = (string)Spartan_BR_TestingData.User_that_reviewed_Spartan_User.Name
                    , Acceptance_Critera          = Spartan_BR_TestingData.Acceptance_Critera
                    , It_worked                   = Spartan_BR_TestingData.It_worked.GetValueOrDefault()
                    , Rejection_Reason            = Spartan_BR_TestingData.Rejection_Reason
                    , Rejection_ReasonDescription = (string)Spartan_BR_TestingData.Rejection_Reason_Spartan_BR_Rejection_Reason.Description
                    , Comments = Spartan_BR_TestingData.Comments
                    , Evidence = Spartan_BR_TestingData.Evidence
                };
                _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                ViewBag.EvidenceSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varSpartan_BR_Testing.Evidence).Resource;
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_UserApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Users_User_that_reviewed = _ISpartan_UserApiConsumer.SelAll(true);

            if (Spartan_Users_User_that_reviewed != null && Spartan_Users_User_that_reviewed.Resource != null)
            {
                ViewBag.Spartan_Users_User_that_reviewed = Spartan_Users_User_that_reviewed.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.Id_User)
                }).ToList();
            }
            _ISpartan_BR_Rejection_ReasonApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_BR_Rejection_Reasons_Rejection_Reason = _ISpartan_BR_Rejection_ReasonApiConsumer.SelAll(true);

            if (Spartan_BR_Rejection_Reasons_Rejection_Reason != null && Spartan_BR_Rejection_Reasons_Rejection_Reason.Resource != null)
            {
                ViewBag.Spartan_BR_Rejection_Reasons_Rejection_Reason = Spartan_BR_Rejection_Reasons_Rejection_Reason.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.Key_Rejection_Reason)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_BR_Testing));
        }
Beispiel #3
0
        public ActionResult AddSpartan_BR_Testing(int rowIndex = 0, int functionMode = 0, int id = 0)
        {
            int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;

            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 35348);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _ISpartan_BR_TestingApiConsumer.SetAuthHeader(_tokenManager.Token);
            Spartan_BR_TestingModel varSpartan_BR_Testing = new Spartan_BR_TestingModel();


            if (id.ToString() != "0")
            {
                var Spartan_BR_TestingsData = _ISpartan_BR_TestingApiConsumer.ListaSelAll(0, 1000, "Spartan_BR_Testing.Key_Testing=" + id, "").Resource.Spartan_BR_Testings;

                if (Spartan_BR_TestingsData != null && Spartan_BR_TestingsData.Count > 0)
                {
                    var Spartan_BR_TestingData = Spartan_BR_TestingsData.First();
                    varSpartan_BR_Testing = new Spartan_BR_TestingModel
                    {
                        Key_Testing                   = Spartan_BR_TestingData.Key_Testing
                        , User_that_reviewed          = Spartan_BR_TestingData.User_that_reviewed
                        , User_that_reviewedName      = (string)Spartan_BR_TestingData.User_that_reviewed_Spartan_User.Name
                        , Acceptance_Critera          = Spartan_BR_TestingData.Acceptance_Critera
                        , It_worked                   = Spartan_BR_TestingData.It_worked.GetValueOrDefault()
                        , Rejection_Reason            = Spartan_BR_TestingData.Rejection_Reason
                        , Rejection_ReasonDescription = (string)Spartan_BR_TestingData.Rejection_Reason_Spartan_BR_Rejection_Reason.Description
                        , Comments = Spartan_BR_TestingData.Comments
                        , Evidence = Spartan_BR_TestingData.Evidence
                    };
                }
                _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                ViewBag.EvidenceSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varSpartan_BR_Testing.Evidence).Resource;
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_UserApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Users_User_that_reviewed = _ISpartan_UserApiConsumer.SelAll(true);

            if (Spartan_Users_User_that_reviewed != null && Spartan_Users_User_that_reviewed.Resource != null)
            {
                ViewBag.Spartan_Users_User_that_reviewed = Spartan_Users_User_that_reviewed.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.Id_User)
                }).ToList();
            }
            _ISpartan_BR_Rejection_ReasonApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_BR_Rejection_Reasons_Rejection_Reason = _ISpartan_BR_Rejection_ReasonApiConsumer.SelAll(true);

            if (Spartan_BR_Rejection_Reasons_Rejection_Reason != null && Spartan_BR_Rejection_Reasons_Rejection_Reason.Resource != null)
            {
                ViewBag.Spartan_BR_Rejection_Reasons_Rejection_Reason = Spartan_BR_Rejection_Reasons_Rejection_Reason.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.Key_Rejection_Reason)
                }).ToList();
            }


            return(PartialView("AddSpartan_BR_Testing", varSpartan_BR_Testing));
        }