Exemplo n.º 1
0
        //Get DepartmentAccess
        public EditDepartmentAccess GetDepartmentAccess(int id)
        {
            DepartmentAccess     departmentAccess     = ctx.DepartmentAccess.Single(e => e.CompanyID == _companyID && e.DepartmentAccessID == id);
            EditDepartmentAccess readDepartmentAccess = new EditDepartmentAccess
            {
                DepartmentAccessID = departmentAccess.DepartmentAccessID,
                DepartmentID       = departmentAccess.DepartmentID,
                DepartmentName     = ctx.Departments.Single(e => e.DepartmentID == departmentAccess.DepartmentID).DepartmentName,
                Username           = ctx.Users.Single(e => e.Id == departmentAccess.UserID).UserName,
                //UserID = departmentAccess.UserID,
                PermissionID = departmentAccess.PermissionID,
                Access       = ctx.Permissions.Single(e => e.PermissionID == departmentAccess.PermissionID).Access,
            };
            CreateHistory history = new CreateHistory
            {
                CompanyID = _companyID,
                UserID    = _userID.ToString(),
                Table     = "DepartmentAccess",
                stringID  = id.ToString(),
                Request   = $"GetDepartmentAccess({id})"
            };

            AddHistory(history);
            return(readDepartmentAccess);
        }
Exemplo n.º 2
0
        //Edit DepartmentAccess
        public bool EditDepartmentAccess(EditDepartmentAccess model)
        {
            DepartmentAccess departmentAccess = ctx.DepartmentAccess.Find(model.DepartmentAccessID);

            if (departmentAccess == null)
            {
                return(false);
            }
            if (departmentAccess.CompanyID != _companyID) //Check that user is in the same company as the requesting user.
            {
                return(false);
            }
            string uID = ctx.Users.Single(e => e.UserNumber == model.UserID).Id;

            departmentAccess.DepartmentID    = model.DepartmentID;
            departmentAccess.UserID          = uID;
            departmentAccess.PermissionID    = model.PermissionID;
            departmentAccess.ModifiedDateUTC = DateTimeOffset.UtcNow;
            CreateHistory history = new CreateHistory
            {
                CompanyID = _companyID,
                UserID    = _userID.ToString(),
                Table     = "DepartmentAccess",
                stringID  = model.DepartmentAccessID.ToString(),
                Request   = Newtonsoft.Json.JsonConvert.SerializeObject(model)
            };

            return(AddHistory(history));
        }
Exemplo n.º 3
0
        public void CheckDepartmentExist()
        {
            var obj = new DepartmentAccess();
            var Res = obj.CheckDeptExist(10);

            Assert.That(Res, Is.True);
        }
Exemplo n.º 4
0
        public void CheckDepartmentExist()
        {
            // arrange
            var obj = new DepartmentAccess();
            // act
            var Res = obj.CheckDeptExist(10);

            // assert
            Assert.That(Res, Is.True);
        }
Exemplo n.º 5
0
        //Delete DepartmentAccess
        public bool DeleteDepartmentAccess(int id)
        {
            DepartmentAccess departmentAccess = ctx.DepartmentAccess.Find(id);

            if (departmentAccess == null)
            {
                return(false);
            }
            if (departmentAccess.CompanyID != _companyID) //Check that user is in the same company as the requesting user.
            {
                return(false);
            }
            ctx.DepartmentAccess.Remove(departmentAccess);
            CreateHistory history = new CreateHistory
            {
                CompanyID = _companyID,
                UserID    = _userID.ToString(),
                Table     = "DepartmentAccess",
                stringID  = id.ToString(),
                Request   = $"DeleteDepartmentAccess({id})"
            };

            return(AddHistory(history));
        }
 public DepartmentController()
 {
     objds = new DepartmentAccess();
 }