// GET: /Create
        public ActionResult Create(int id)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToApprovalGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ApprovalItemVM approvalItemVM = new ApprovalItemVM();

            ApprovalGroup approvalGroup = new ApprovalGroup();

            approvalGroup = approvalGroupRepository.GetGroup(id);
            if (approvalGroup != null)
            {
                ApprovalItem approvalItem = new ApprovalItem();
                approvalItem.ApprovalGroupId  = approvalGroup.ApprovalGroupId;
                approvalItemVM.ApprovalItem   = approvalItem;
                ViewData["ApprovalGroupId"]   = approvalGroup.ApprovalGroupId;
                ViewData["ApprovalGroupName"] = approvalGroup.ApprovalGroupName;
            }

            return(View(approvalItemVM));
        }
        // GET: /View
        public ActionResult View(int id)
        {
            ApprovalItem approvalItem = new ApprovalItem();

            approvalItem = approvalItemRepository.ApprovalItem(id);

            //Check Exists
            if (approvalItem == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            ApprovalItemVM approvalItemVM = new ApprovalItemVM();

            approvalItemVM.ApprovalItem = approvalItem;

            ApprovalGroup approvalGroup = new ApprovalGroup();

            approvalGroup = approvalGroupRepository.GetGroup(approvalItem.ApprovalGroupId);
            if (approvalGroup != null)
            {
                approvalItem.ApprovalGroupId  = approvalGroup.ApprovalGroupId;
                approvalItemVM.ApprovalItem   = approvalItem;
                ViewData["ApprovalGroupId"]   = approvalGroup.ApprovalGroupId;
                ViewData["ApprovalGroupName"] = approvalGroup.ApprovalGroupName;
            }

            return(View(approvalItemVM));
        }
Esempio n. 3
0
        //Delete From DB
        public void Delete(ApprovalItem ApprovalItem)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteApprovalItem_v1(
                ApprovalItem.ApprovalItemId,
                adminUserGuid,
                ApprovalItem.VersionNumber
                );
        }
Esempio n. 4
0
        //Update in DB
        public void Update(ApprovalItem approvalItem)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_UpdateApprovalItem_v1(
                approvalItem.ApprovalItemId,
                approvalItem.ApproverDescription,
                approvalItem.RemarkText,
                adminUserGuid,
                approvalItem.VersionNumber
                );
        }
Esempio n. 5
0
        //Add to DB
        public void Add(ApprovalItem approvalItem)
        {
            string adminUserGuid  = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];
            int?   approvalItemId = new Int32();

            db.spDesktopDataAdmin_InsertApprovalItem_v1(
                ref approvalItemId,
                approvalItem.ApproverDescription,
                approvalItem.RemarkText,
                approvalItem.ApprovalGroupId,
                adminUserGuid
                );

            approvalItem.ApprovalItemId = (int)approvalItemId;
        }
        public ActionResult Delete(ApprovalItemVM approvalItemVM)
        {
            //Get Item From Database
            ApprovalItem approvalItem = new ApprovalItem();

            approvalItem = approvalItemRepository.ApprovalItem(approvalItemVM.ApprovalItem.ApprovalItemId);

            //Check Exists
            if (approvalItem == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToApprovalGroup(approvalItemVM.ApprovalItem.ApprovalGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Delete Item
            try
            {
                approvalItemRepository.Delete(approvalItem);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ApprovalItem.mvc/Delete/" + approvalItem.ApprovalItemId;
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            return(RedirectToAction("List", new { id = approvalItemVM.ApprovalItem.ApprovalGroupId }));
        }
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get Item From Database
            ApprovalItem approvalItem = new ApprovalItem();

            approvalItem = approvalItemRepository.ApprovalItem(id);

            //Check Exists
            if (approvalItem == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToApprovalGroup(approvalItem.ApprovalGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ApprovalItemVM approvalItemVM = new ApprovalItemVM();

            approvalItemRepository.EditForDisplay(approvalItem);

            ApprovalGroup approvalGroup = new ApprovalGroup();

            approvalGroup = approvalGroupRepository.GetGroup(approvalItem.ApprovalGroupId);
            if (approvalGroup != null)
            {
                approvalItem.ApprovalGroupId  = approvalGroup.ApprovalGroupId;
                approvalItemVM.ApprovalItem   = approvalItem;
                ViewData["ApprovalGroupId"]   = approvalGroup.ApprovalGroupId;
                ViewData["ApprovalGroupName"] = approvalGroup.ApprovalGroupName;
            }

            return(View(approvalItemVM));
        }
Esempio n. 8
0
 public ApprovalItemVM(ApprovalItem approvalItem, ApprovalGroup approvalGroup)
 {
     ApprovalItem  = approvalItem;
     ApprovalGroup = approvalGroup;
 }
Esempio n. 9
0
 //Add Data From Linked Tables for Display
 public void EditForDisplay(ApprovalItem ApprovalItem)
 {
 }