Пример #1
0
        //Use the below code from cshtml view to get the submit button
        //@Html.OpMgrSubmitButton("submitButton", "my submit button label", new { onclick = "alert('abc');", @class = "btn btn-primary", id="myId" })
        public static MvcHtmlString OpMgrSubmitButton(this HtmlHelper helper, string name, string label, object htmlAttributes)
        {
            string controlText = helper.TextBox(name, label, htmlAttributes).ToString();

            controlText = controlText.Replace("type=\"text\"", "type=\"submit\"");
            if (htmlAttributes != null)
            {
                object objId = GetPropValue(htmlAttributes, "id");
                if (objId != null)
                {
                    string id = objId.ToString();
                    OpMgr.Common.DTOs.SessionDTO session = _sessionSvc.GetUserSession();
                    var disabledControl = session.ActionList.FirstOrDefault(a => string.Equals(a.DisabledControlId, id) && string.Equals(a.ParentAction.ActionLink, System.Web.HttpContext.Current.Request.Path));
                    var hiddenControl   = session.ActionList.FirstOrDefault(a => string.Equals(a.HiddenControlId, id) && string.Equals(a.ParentAction.ActionLink, System.Web.HttpContext.Current.Request.Path));
                    if (hiddenControl != null)
                    {
                        return(new MvcHtmlString(""));
                    }
                    if (disabledControl != null)
                    {
                        var editorField = new TagBuilder("span");
                        editorField.AddCssClass("disabledDiv");
                        editorField.InnerHtml += controlText;

                        return(MvcHtmlString.Create(editorField.ToString()));
                    }
                }
            }
            return(MvcHtmlString.Create(controlText));
        }
Пример #2
0
        public ActionResult Login(UserMasterDTO data)
        {
            List <EntitlementDTO> lstEntitleMent = new List <EntitlementDTO>();
            List <ActionDTO>      lstAction      = new List <ActionDTO>();
            string unencryptedPass = data.Password;
            string pass            = encrypt.encryption(data.Password);

            data.Password = pass;

            StatusDTO <UserMasterDTO> status = _userSvc.Login(data, out lstEntitleMent, out lstAction);

            if (status.IsSuccess)
            {
                if (data.RememberMe)
                {
                    HttpCookie cookie = new HttpCookie("userDetails");
                    cookie["uid"]  = data.UserName;
                    cookie["pwd"]  = unencryptedPass;
                    cookie.Expires = DateTime.Now + new TimeSpan(1, 0, 0, 0);

                    if (Request.Cookies["userDetails"] != null)
                    {
                        Response.Cookies.Set(cookie);
                    }
                    else
                    {
                        Response.Cookies.Add(cookie);
                    }
                }
                else
                {
                    Response.Cookies.Remove("userDetails");
                }

                SessionDTO session = new SessionDTO();
                session.UserMasterId    = status.ReturnObj.UserMasterId;
                session.UserName        = status.ReturnObj.UserName;
                session.FName           = status.ReturnObj.FName;
                session.MName           = status.ReturnObj.MName;
                session.LName           = status.ReturnObj.LName;
                session.ActionList      = lstAction;
                session.EntitleMentList = lstEntitleMent;


                _sessionSvc.SetUserSession(session);
                SessionDTO sessionRet = _sessionSvc.GetUserSession();
            }
            else
            {
                data.LoginFailedMsg = status.FailureReason;
                return(View(data));
            }

            return(RedirectToAction("Landing", "Login", new { area = "Login" }));;
        }
Пример #3
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            SessionDTO session = _sessionSvc.GetUserSession();

            if (session == null)
            {
                return(false);
            }
            var url = session.ActionList.FirstOrDefault(al => httpContext.Request.Path.ToUpper().Contains(al.ActionLink.ToUpper()));

            if (url != null)
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        public ActionResult PromotionBatch(StudentVM studView)
        {
            bool     isSuccess = false;
            int      loggedInUser;
            DateTime date;
            string   status;// right now hard coded

            if (studView != null)
            {
                SessionDTO sessionRet = _sessionSvc.GetUserSession();//Get Data from User Seesion
                status       = "Promotion Confirmed";
                loggedInUser = sessionRet.UserMasterId;
                if (status != null && loggedInUser != 0)
                {
                    isSuccess = _studSvc.UpdatePromotedStudents(loggedInUser, status);
                    if (isSuccess)
                    {
                        date = DateTime.Now;
                        studView.SuccessOrFailureMessage = "The students of all classes have been promoted for academic year" + (int)(date.Year - 1) + "/" + (date.Year);
                        studView.MsgColor = "green";
                    }
                    else
                    {
                        studView.SuccessOrFailureMessage = "All students have not been Promoted yet";
                        studView.MsgColor = "red";
                    }
                }
            }
            return(View(studView));
        }
        public ActionResult MyTransactions(Models.TransactionViewModel trVM)
        {
            SessionDTO session = _sessionSvc.GetUserSession();

            trVM.User = new UserMasterDTO();
            trVM.User.UserMasterId = session.UserMasterId;
            StatusDTO <List <TransactionLogDTO> > status = _transactionLog.Select(trVM);

            if (status.IsSuccess)
            {
                trVM.SearchResult = new List <Models.TransactionViewModel>();
                if (status.ReturnObj != null && status.ReturnObj.Count > 0)
                {
                    Models.TransactionViewModel trSR = null;
                    for (int i = 0; i < status.ReturnObj.Count; i++)
                    {
                        trSR = new Models.TransactionViewModel();

                        trSR.User                   = new UserMasterDTO();
                        trSR.User.FName             = status.ReturnObj[i].User.FName;
                        trSR.User.MName             = status.ReturnObj[i].User.MName;
                        trSR.User.LName             = status.ReturnObj[i].User.LName;
                        trSR.TransactionLogId       = status.ReturnObj[i].TransactionLogId;
                        trSR.TransactionDate        = status.ReturnObj[i].TransactionDate;
                        trSR.TransactionDueDate     = status.ReturnObj[i].TransactionDueDate;
                        trSR.ParentTransactionLogId = status.ReturnObj[i].ParentTransactionLogId;
                        trSR.IsCompleted            = status.ReturnObj[i].IsCompleted;
                        trSR.CompletedOn            = status.ReturnObj[i].CompletedOn;
                        trSR.AmountImposed          = status.ReturnObj[i].AmountImposed;
                        trSR.AmountGiven            = status.ReturnObj[i].AmountGiven;
                        trSR.DueAmount              = status.ReturnObj[i].DueAmount;
                        trSR.TransferMode           = status.ReturnObj[i].TransferMode;
                        trSR.Location               = status.ReturnObj[i].Location;
                        trSR.TransactionType        = status.ReturnObj[i].TransactionType;
                        trSR.HasPenalty             = status.ReturnObj[i].HasPenalty;
                        trSR.OriginalTransLog       = status.ReturnObj[i].OriginalTransLog;
                        trSR.TransactionRule        = status.ReturnObj[i].TransactionRule;

                        trVM.SearchResult.Add(trSR);
                    }
                }
                else
                {
                    trVM.Message = new MvcHtmlString("No related transaction record found.");
                }
            }
            else
            {
                trVM.SearchResult = null;
                trVM.Message      = new MvcHtmlString("Query returned with error.");
            }

            Helpers.UIDropDownRepo uiDDLRepo = new Helpers.UIDropDownRepo(_ddlRepo);

            trVM.StandardSectionList = uiDDLRepo.getStandardSectionDropDown();
            trVM.TransactionTypeList = uiDDLRepo.getTransactionTypes();

            return(View(trVM));
        }
Пример #6
0
        public List <MenuModel> GetMenuItems(ISessionSvc sessionSvc)
        {
            SessionDTO       sessionDto = sessionSvc.GetUserSession();
            List <ActionDTO> actions    = new List <ActionDTO>();

            actions = sessionDto.ActionList;
            List <MenuModel> lstMenu = null;

            if (actions != null)
            {
                lstMenu = new List <MenuModel>();
                MenuModel menu;
                for (int i = 0; i < actions.Count; i++)
                {
                    if (!string.IsNullOrEmpty(actions[i].ActionLink) && !string.IsNullOrEmpty(actions[i].MenuText) && string.IsNullOrEmpty(actions[i].HiddenControlId) && string.IsNullOrEmpty(actions[i].DisabledControlId))
                    {
                        string menuText = OpMgr.Resources.Common.MenuResource.ResourceManager.GetString(actions[i].MenuText);
                        if (string.IsNullOrEmpty(actions[i].GroupName))
                        {
                            menu = lstMenu.FirstOrDefault(m => string.Equals(m.MenuCode, actions[i].MenuText));
                            if (menu == null)
                            {
                                menu                    = new MenuModel();
                                menu.MenuImage          = actions[i].MenuImage;
                                menu.MenuText           = menuText;
                                menu.IsSelfRedirectable = true;
                                menu.ChildItems         = null;
                                menu.UrlToRedirect      = actions[i].ActionLink;
                                menu.MenuCode           = actions[i].MenuText;

                                if (string.Equals(menu.UrlToRedirect, HttpContext.Current.Request.Path, StringComparison.OrdinalIgnoreCase))
                                {
                                    menu.IsSelected = true;
                                }

                                lstMenu.Add(menu);
                            }
                        }
                        else
                        {
                            menu                    = new MenuModel();
                            menu.MenuImage          = actions[i].MenuImage;
                            menu.MenuText           = menuText;
                            menu.IsSelfRedirectable = true;
                            menu.ChildItems         = null;
                            menu.UrlToRedirect      = actions[i].ActionLink;
                            menu.MenuCode           = actions[i].MenuText;

                            if (string.Equals(menu.UrlToRedirect, HttpContext.Current.Request.Path, StringComparison.OrdinalIgnoreCase))
                            {
                                menu.IsSelected = true;
                            }

                            string    groupName = OpMgr.Resources.Common.MenuResource.ResourceManager.GetString(actions[i].GroupName);
                            MenuModel addedRoot = lstMenu.FirstOrDefault(m => string.Equals(m.MenuCode, actions[i].GroupName));
                            if (addedRoot == null)
                            {
                                addedRoot                    = new MenuModel();
                                addedRoot.ChildItems         = null;
                                addedRoot.IsSelfRedirectable = false;
                                addedRoot.MenuText           = groupName;
                                addedRoot.UrlToRedirect      = string.Empty;
                                addedRoot.MenuCode           = actions[i].GroupName;
                                lstMenu.Add(addedRoot);
                            }
                            if (addedRoot.ChildItems == null)
                            {
                                addedRoot.ChildItems = new List <MenuModel>();
                                addedRoot.ChildItems.Add(menu);
                            }
                            else
                            {
                                if (addedRoot.ChildItems.FirstOrDefault(m => string.Equals(m.MenuCode, actions[i].MenuText)) == null)
                                {
                                    addedRoot.ChildItems.Add(menu);
                                }
                            }
                        }
                    }
                }
            }

            return(lstMenu);
        }