Example #1
0
        public string GetToken(ClsReturnValues audience, int UserGroupID)
        {
            // TODO - Authenticate credentials here
            // TODO - Based on the audience passed in, pick the shared key from key store
            // Just hard-coding a key heress
            string key = "qqO5yXcbijtAdYmS2Otyzeze2XQedqy+Tp37wQ3sgTQ=";

            SimpleWebToken token = new SimpleWebToken(key)
            {
                Issuer = "tdoCloud"
            };

            //verify the user from the database
            token.AddClaim(ClaimTypes.Name, audience.ID.ToString());
            //token.AddClaim(ClaimTypes.Email, "*****@*****.**");
            using (tdoEntities db = new tdoEntities())
            {
                var groupName = db.uspGetUserGroups().ToList <ClsUserGroups>().Where(p => p.userGroupID == UserGroupID).First().groupName;
                token.AddClaim(ClaimTypes.Role, groupName);
                token.AddClaim("GroupID", UserGroupID.ToString());
            }

            //token.AddClaim(ClaimTypes.Role, "Administrator");
            return(token.ToString());
        }
        public JsonResult setRegister(string tdoRegisterID, string jobNumber, string dateReceived, string expiryDate, string status, string cargoTypeID, string fileRef,
                                      string destinationID, string terminalID, string containerNo, string returnTerminal, string truckID, string tdoReceiptDate, string schDelDate,
                                      string remarks, string createdByID, string sessionID)
        {
            List <ClsUserDisplay> userDisplay = new List <ClsUserDisplay>();

            using (tdoEntities db = new tdoEntities())
            {
                userDisplay = db.uspGetUserDisplay(GetID()).ToList <ClsUserDisplay>();
            }
            List <string> editableForms = Restriction.GetEditableForms(userDisplay);
            List <string> addableForms  = Restriction.GetAddableForms(userDisplay);

            if (int.Parse(tdoRegisterID) == 0 && !addableForms.Contains("Register"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." }));
            }
            else if (int.Parse(tdoRegisterID) != 0 && !editableForms.Contains("Register"))
            {
                return(Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." }));
            }

            if (tdoRegisterID == "")
            {
                tdoRegisterID = "0";
            }

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int  _id     = 0;

            try { _id = int.Parse(tdoRegisterID.Trim()); }
            catch { }
            ClsRegister obj = new ClsRegister()
            {
                tdoRegisterID  = _id,
                jobNumber      = jobNumber,
                dateReceived   = StringToArray.ConvertToDate(dateReceived),
                expiryDate     = StringToArray.ConvertToDate(expiryDate),
                status         = status,
                cargoTypeID    = int.Parse(cargoTypeID),
                fileRef        = fileRef,
                destinationID  = int.Parse(destinationID),
                terminalID     = int.Parse(terminalID),
                containerNo    = containerNo,
                returnTerminal = int.Parse(returnTerminal),
                truckID        = int.Parse(truckID),
                tdoReceiptDate = StringToArray.ConvertToDate(tdoReceiptDate),
                schDelDate     = StringToArray.ConvertToDate(schDelDate),
                remarks        = remarks,
                createdByID    = GetID(),
                sessionID      = Session
            };
            ClsReturnValues k = Modules.setRegister(obj);

            return(Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }));
        }
Example #3
0
        public static ClsReturnValues setPort(ClsPort obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditPort(obj.portID, obj.portName, obj.locationID, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #4
0
        public static ClsReturnValues setTerminal(ClsTerminal obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditTerminal(obj.terminalID, obj.terminalName, obj.portID, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #5
0
        public static ClsReturnValues delActiveSessions(Guid sessionID, int userID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelUserSession(sessionID, userID).FirstOrDefault();
            }
            return(lst);
        }
Example #6
0
        public static ClsReturnValues delLocation(int locationID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelLocation(locationID).FirstOrDefault();
            }
            return(lst);
        }
Example #7
0
        public static ClsReturnValues setRegion(ClsRegion obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditRegion(obj.regionID, obj.regionName, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #8
0
        public static ClsReturnValues setCity(ClsCity obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditCity(obj.cityID, obj.cityName, obj.cityCode, obj.stateID, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #9
0
        public static ClsReturnValues setUsersGroup(ClsUserGroups obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditUserGroups(obj.userGroupID, obj.groupName, obj.description ?? "", obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #10
0
        public static ClsReturnValues setDriver(ClsDriver obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditDriver(obj.driverID, obj.driverCode, obj.firstName, obj.middleName, obj.lastName, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #11
0
        public static ClsReturnValues delCargoType(int cargoTypeID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelCargoType(cargoTypeID).FirstOrDefault();
            }
            return(lst);
        }
Example #12
0
        public static ClsReturnValues setCargoType(ClsCargoType obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditCargoType(obj.cargoTypeID, obj.cargoTypeName, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #13
0
        public static ClsReturnValues delRegister(int tdoRegisterID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelRegister(tdoRegisterID).FirstOrDefault();
            }
            return(lst);
        }
Example #14
0
        public static ClsReturnValues setForms(ClsForms obj)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditForms(obj.formID, obj.menuItemID, obj.formName, obj.formDescription, obj.createdByID, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #15
0
        public static ClsReturnValues delUsers(int userID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelUsers(userID).FirstOrDefault();
            }
            return(lst);
        }
Example #16
0
        public static ClsReturnValues delMenuIcons(int menuIconID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelMenuIcons(menuIconID).FirstOrDefault();
            }
            return(lst);
        }
Example #17
0
        public static ClsReturnValues setTruck(ClsTruck obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditTruck(obj.truckID, obj.truckName, obj.regNumb, obj.truckTypeID, obj.createdByID, SessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #18
0
        public static ClsReturnValues setAccessLevel(ClsAccessLevels obj)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditAccessLevels(obj.accessLevelID, obj.userGroupID, obj.formID, obj.canAdd, obj.canView, obj.canEdit, obj.canDelete, obj.canApprove, obj.createdByID, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #19
0
        public static ClsReturnValues setMenuIcons(ClsMenuIcons obj)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditMenuIcons(obj.menuIconID, obj.menuID, obj.menuIconName).FirstOrDefault();
            }
            return(lst);
        }
Example #20
0
        public static ClsReturnValues setMenus(ClsMenus obj)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditMenus(obj.menuID, obj.menuName, obj.menuDesc, obj.createdByID, obj.menuRanking, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #21
0
        public static ClsReturnValues delTruck(int truckID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspDelTruck(truckID).FirstOrDefault();
            }
            return(lst);
        }
Example #22
0
        public static ClsReturnValues changePassword(int userID, string oldPassword, string newPassword)
        {
            newPassword = Security.Encrypt(newPassword);
            oldPassword = Security.Encrypt(oldPassword);
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspChangePassword(userID, oldPassword, newPassword).FirstOrDefault();
            }
            return(lst);
        }
Example #23
0
        public static ClsReturnValues setRegister(ClsRegister obj)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditRegister(obj.tdoRegisterID, obj.jobNumber, obj.dateReceived, obj.expiryDate, obj.status, obj.cargoTypeID, obj.fileRef, obj.destinationID,
                                            obj.terminalID, obj.containerNo, obj.returnTerminal, obj.truckID, obj.tdoReceiptDate, obj.schDelDate, obj.loadingTime, obj.dispatchTime,
                                            obj.remarks, obj.createdByID, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #24
0
        public ActionResult LogOut()
        {
            Guid            session  = Guid.Parse(Session["SessionID"].ToString());
            int             userid   = int.Parse(Session["UserID"].ToString());
            ClsReturnValues returned = Login.delUserSession(session, userid);

            if (returned.IsSuccess == true)
            {
                Session.RemoveAll();
            }
            return(RedirectToAction("Index", "Login"));
        }
Example #25
0
        public static ClsReturnValues setUsers(ClsUsers obj)
        {
            //password encryption happens here
            obj.password = Security.Encrypt(obj.password);

            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditUsers(obj.userID, obj.userGroupID, obj.userName, obj.password, obj.password, obj.passwordCanExpire, obj.passwordExpiryDate, obj.isLocked, obj.loginAttempts, obj.lastLoginDate, obj.theme, obj.resetPassword, obj.createdByID, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Example #26
0
        public static ClsReturnValues resetPassword(int userID, string newPassword)
        {
            newPassword = Security.Encrypt(newPassword);
            ClsUsers        U           = Administration.getUsers().Where(p => p.userID == userID).ToList().FirstOrDefault();
            string          oldPassword = U.password;
            ClsReturnValues lst         = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspChangePassword(userID, oldPassword, newPassword).FirstOrDefault();
            }
            return(lst);
        }
Example #27
0
        public JsonResult setCargoType(int cargoTypeID, string cargoTypeName, int createdByID)
        {
            createdByID = 1;
            ClsCargoType obj = new ClsCargoType()
            {
                cargoTypeID   = cargoTypeID,
                cargoTypeName = cargoTypeName,
                createdByID   = createdByID
            };
            ClsReturnValues k = Setup.setCargoType(obj);

            return(Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }));
        }
Example #28
0
        public static ClsReturnValues setCargoType(ClsCargoType item)
        {
            ClsReturnValues obj = new ClsReturnValues();

            try
            {
                using (var db = new tdoEntities())
                {
                    obj = db.uspAddEditCargoType(item.cargoTypeID, item.cargoTypeName, item.createdByID, item.sessionID).FirstOrDefault();
                }
            }
            catch (Exception ex) { obj.Response = ex.Message; obj.IsSuccess = false; obj.ID = 0; }
            return(obj);
        }
Example #29
0
        public static ClsReturnValues setUserSessionHistory(ClsUserSessionHistory item)
        {
            ClsReturnValues obj = new ClsReturnValues();

            try
            {
                using (var db = new tdoEntities())
                {
                    obj = db.uspAddEditUserSessionHistory(item.sessionID, item.userID, item.logoutDate, item.isActive, item.deviceType, item.deviceName, item.browser).FirstOrDefault();
                }
            }
            catch (Exception ex) { obj.Response = ex.Message; obj.IsSuccess = false; obj.ID = 0; }
            return(obj);
        }
Example #30
0
        public static ClsReturnValues setUserSessions(ClsUserSessions item)
        {
            ClsReturnValues obj = new ClsReturnValues();

            try
            {
                using (var db = new tdoEntities())
                {
                    //uspAddEditUserSessions(Guid? sessionID, int? userID, bool? isActive, string deviceType, string deviceName, string browser, int? companyID);
                    obj = db.uspAddEditUserSessions(item.sessionID, item.userID, item.isActive, item.deviceType, item.deviceName, item.browser).FirstOrDefault();
                }
            }
            catch (Exception ex) { obj.Response = ex.Message; obj.IsSuccess = false; obj.ID = 0; }
            return(obj);
        }