Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="i_sConnectionString"></param>
        /// <param name="i_nUserInfoId"></param>
        /// <param name="o_nReturnValue"></param>
        /// <param name="o_nErroCode"></param>
        /// <param name="o_sErrorMessage"></param>
        /// <returns></returns>
        public InsiderTradingDAL.RoleMasterDTO GetRoleMasterDetails(string i_sConnectionString, int i_nRoleId)
        {
            InsiderTradingDAL.RoleMasterDTO res = null;

            try
            {
                //InsiderTradingDAL.RoleMasterDAL objRoleMaterDAL = new InsiderTradingDAL.RoleMasterDAL();
                using (var objRoleMasterDAL = new InsiderTradingDAL.RoleMasterDAL())
                {
                    res = objRoleMasterDAL.GetDetails(i_sConnectionString, i_nRoleId);
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(res);
        }
Esempio n. 2
0
        public ActionResult Create(int RoleId, int acid, string frm = "", int uid = 0)
        {
            LoginUserDetails        objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails);
            PopulateComboDTO        objPopulateComboDTO = new PopulateComboDTO();
            List <PopulateComboDTO> lstRoleStatusList   = new List <PopulateComboDTO>();
            List <PopulateComboDTO> lstUserTypeList     = new List <PopulateComboDTO>();

            try
            {
                objPopulateComboDTO.Key   = "0";
                objPopulateComboDTO.Value = "Select";
                lstRoleStatusList.Add(objPopulateComboDTO);
                lstRoleStatusList.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode,
                                                                          Convert.ToInt32(ConstEnum.CodeGroup.RoleStatus).ToString(), null, null, null, null, "usr_msg_").ToList <PopulateComboDTO>());

                lstUserTypeList.Add(objPopulateComboDTO);
                lstUserTypeList.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode,
                                                                        Convert.ToInt32(ConstEnum.CodeGroup.UserType).ToString(), null, null, null, null, "usr_msg_").ToList <PopulateComboDTO>());

                ViewBag.RoleStatus = lstRoleStatusList; // new SelectList(lstRoleStatusList, "Key", "Value");
                ViewBag.UserType   = lstUserTypeList;

                //set varible to check if user come on role page from role menu option or from employee/insider create/edit page
                string link_from = "";
                int    user_id   = 0;
                ViewBag.vwbUserTypeCodeId = 0;
                if (frm != "")
                {
                    link_from = frm;
                    user_id   = uid;
                    switch (frm)
                    {
                    case "emp":     //link from employee page
                        ViewBag.vwbUserTypeCodeId = ConstEnum.Code.EmployeeType;
                        ViewBag.UserTypeCodeId    = ConstEnum.Code.EmployeeType;
                        break;

                    case "nonemp":     //link from non employee page
                        ViewBag.vwbUserTypeCodeId = ConstEnum.Code.NonEmployeeType;
                        ViewBag.UserTypeCodeId    = ConstEnum.Code.NonEmployeeType;
                        break;

                    case "corp":     //link from corporate employee page
                        ViewBag.vwbUserTypeCodeId = ConstEnum.Code.CorporateUserType;
                        ViewBag.UserTypeCodeId    = ConstEnum.Code.CorporateUserType;
                        break;

                    case "cousr":     //link from CO user page
                        ViewBag.vwbUserTypeCodeId = ConstEnum.Code.COUserType;
                        ViewBag.UserTypeCodeId    = ConstEnum.Code.COUserType;
                        break;

                    default:
                        //default return to role master list page
                        break;
                    }
                }
                ViewBag.link_from = link_from;
                ViewBag.user_id   = user_id;

                ViewBag.user_action = acid;

                if (RoleId > 0)
                {
                    RoleMasterSL    objRoleMasterSL    = new RoleMasterSL();
                    RoleMasterModel objRoleMasterModel = new RoleMasterModel();
                    InsiderTradingDAL.RoleMasterDTO objRoleMasterDTO = objRoleMasterSL.GetRoleMasterDetails(objLoginUserDetails.CompanyDBConnectionString, RoleId);
                    InsiderTrading.Common.Common.CopyObjectPropertyByName(objRoleMasterDTO, objRoleMasterModel);
                    ViewBag.IsDefault          = objRoleMasterModel.IsDefault;
                    ViewBag.IsActivityAssigned = objRoleMasterDTO.IsActivityAssigned;
                    if (frm != "")
                    {
                        return(PartialView("Create", objRoleMasterModel));
                    }
                    else
                    {
                        return(View("Create", objRoleMasterModel));
                    }
                }
                else
                {
                    ViewBag.IsActivityAssigned = 0;
                    ViewBag.IsDefault          = false;
                    if (frm != "")
                    {
                        return(PartialView("Create"));
                    }
                    else
                    {
                        return(View("Create"));
                    }
                }
            }
            catch (Exception exp)
            {
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("Error", sErrMessage);
                return(View("View1"));
            }
            finally
            {
                objLoginUserDetails = null;
                objPopulateComboDTO = null;
                lstRoleStatusList   = null;
                lstUserTypeList     = null;
            }
        }
Esempio n. 3
0
        public ActionResult Create(RoleMasterModel objRoleMasterModel, int acid = 0, string frm = "", int uid = 0)
        {
            LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
            RoleMasterSL     objRoleMasterSL     = new RoleMasterSL();

            InsiderTradingDAL.RoleMasterDTO objRoleMasterDTO = new InsiderTradingDAL.RoleMasterDTO();
            PopulateComboDTO        objPopulateComboDTO      = new PopulateComboDTO();
            List <PopulateComboDTO> lstRoleStatusList        = new List <PopulateComboDTO>();
            List <PopulateComboDTO> lstUserTypeList          = new List <PopulateComboDTO>();

            try
            {
                if (Request.Params["authorization"] != null && Request.Params["authorization"] != "")
                {
                    acid = Convert.ToInt32(Request.Params["authorization"].Split(':')[1]);
                }
                InsiderTrading.Common.Common.CopyObjectPropertyByName(objRoleMasterModel, objRoleMasterDTO);
                objRoleMasterDTO = objRoleMasterSL.InsertUpdateRoleMasterDetails(objLoginUserDetails.CompanyDBConnectionString, objRoleMasterDTO, objLoginUserDetails.LoggedInUserID);

                //check from where create role page is called and redirect back to same page
                if (frm != "")
                {
                    return(Json(new
                    {
                        status = true,
                        url = Url.Action("Index", "RoleActivity", new { RoleId = objRoleMasterDTO.RoleId, CalledFrom = frm, acid = Common.ConstEnum.UserActions.CRUSER_ROLEMASTER_EDIT, uid = uid }),
                        RoleId = objRoleMasterDTO.RoleId,
                        CalledFrom = frm,
                        RoleName = objRoleMasterDTO.RoleName,
                        IsActive = (objRoleMasterDTO.StatusCodeId == ConstEnum.Code.RoleStatusActive ? true : false),
                        uid = uid
                    }));
                    //return PartialView("RedirectToRoleActivity");
                    //return RedirectToAction("Index", "RoleActivity", new { RoleId = objRoleMasterDTO.RoleId, CalledFrom = frm, acid = ConstEnum.UserActions.CRUSER_ROLEMASTER_CREATE, uid = uid }).Success(Common.Common.getResource("usr_msg_12053"));
                }
                return(RedirectToAction("Index", "RoleMaster", new { acid = Common.ConstEnum.UserActions.CRUSER_ROLEMASTER_VIEW }).Success(Common.Common.getResource("usr_msg_12053")));
            }
            catch (Exception exp)
            {
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("Error", sErrMessage);
                if (frm != "")
                {
                    return(Json(new
                    {
                        status = false,
                        error = ModelState.ToSerializedDictionary(),
                        Message = sErrMessage
                    }));
                }
                else
                {
                    var RoleId = objRoleMasterModel.RoleId;
                    ViewBag.IsActivityAssigned = 0;
                    objPopulateComboDTO.Key    = "0";
                    objPopulateComboDTO.Value  = "Select";

                    lstRoleStatusList.Add(objPopulateComboDTO);
                    lstRoleStatusList.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode,
                                                                              Convert.ToInt32(ConstEnum.CodeGroup.RoleStatus).ToString(), null, null, null, null, "usr_msg_").ToList <PopulateComboDTO>());

                    lstUserTypeList.Add(objPopulateComboDTO);
                    lstUserTypeList.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode,
                                                                            Convert.ToInt32(ConstEnum.CodeGroup.UserType).ToString(), null, null, null, null, "usr_msg_").ToList <PopulateComboDTO>());

                    //ViewBag.RoleStatus = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.RoleStatus).ToString(), null, null, null, null, true);
                    //ViewBag.UserType = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.UserType).ToString(), null, null, null, null, true);
                    ViewBag.RoleStatus = lstRoleStatusList; // new SelectList(lstRoleStatusList, "Key", "Value");
                    ViewBag.UserType   = lstUserTypeList;
                    if (RoleId > 0)
                    {
                        objRoleMasterDTO           = objRoleMasterSL.GetRoleMasterDetails(objLoginUserDetails.CompanyDBConnectionString, RoleId);
                        ViewBag.IsActivityAssigned = objRoleMasterDTO.IsActivityAssigned;
                    }
                    ViewBag.IsDefault = objRoleMasterModel.IsDefault;

                    //set varible to check if user come on role page from role menu option or from employee/insider create/edit page
                    string link_from = "";
                    int    user_id   = 0;
                    ViewBag.vwbUserTypeCodeId = 0;
                    if (frm != "")
                    {
                        link_from = frm;
                        user_id   = uid;
                        switch (frm)
                        {
                        case "emp":     //link from employee page
                            ViewBag.vwbUserTypeCodeId = ConstEnum.Code.EmployeeType;
                            ViewBag.UserTypeCodeId    = ConstEnum.Code.EmployeeType;
                            break;

                        case "nonemp":     //link from non employee page
                            ViewBag.vwbUserTypeCodeId = ConstEnum.Code.NonEmployeeType;
                            ViewBag.UserTypeCodeId    = ConstEnum.Code.NonEmployeeType;
                            break;

                        case "corp":     //link from corporate employee page
                            ViewBag.vwbUserTypeCodeId = ConstEnum.Code.CorporateUserType;
                            ViewBag.UserTypeCodeId    = ConstEnum.Code.CorporateUserType;
                            break;

                        case "cousr":     //link from CO user page
                            ViewBag.vwbUserTypeCodeId = ConstEnum.Code.COUserType;
                            ViewBag.UserTypeCodeId    = ConstEnum.Code.COUserType;
                            break;

                        default:
                            //default return to role master list page
                            break;
                        }
                    }
                    ViewBag.link_from = link_from;
                    ViewBag.user_id   = user_id;

                    ViewBag.user_action = acid;

                    return(View("Create", objRoleMasterModel));
                }
            }
            finally
            {
                objLoginUserDetails = null;
                objRoleMasterSL     = null;
                objRoleMasterDTO    = null;
                objPopulateComboDTO = null;
                lstRoleStatusList   = null;
                lstUserTypeList     = null;
            }
        }
Esempio n. 4
0
        public RoleMasterDTO InsertUpdateRoleMasterDetails(string sConnectionString, RoleMasterDTO m_objRoleMasterDTO, int nLoggedInUserId)
        {
            #region Paramters
            int    out_nReturnValue;
            int    out_nSQLErrCode;
            string out_sSQLErrMessage;
            #endregion Paramters

            try
            {
                #region Out Paramter
                var nout_nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
                nout_nReturnValue.Direction = System.Data.ParameterDirection.Output;
                nout_nReturnValue.Value     = 0;
                var nout_nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
                nout_nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
                nout_nSQLErrCode.Value     = 0;
                var sout_sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.NVarChar);
                sout_sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
                sout_sSQLErrMessage.Value     = string.Empty;
                #endregion Out Paramter

                using (var db = new PetaPoco.Database(sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        var res = db.Query <RoleMasterDTO>("exec st_usr_RoleMasterSave @inp_iRoleId,@inp_sRoleName,@inp_sDescription,@inp_iStatusCodeId,@inp_iUserTypeCodeId,@inp_iIsDefault,@inp_iLoggedInUserId,@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                           new
                        {
                            @inp_iRoleId         = m_objRoleMasterDTO.RoleId,
                            @inp_sRoleName       = m_objRoleMasterDTO.RoleName,
                            @inp_sDescription    = m_objRoleMasterDTO.Description,
                            @inp_iStatusCodeId   = m_objRoleMasterDTO.StatusCodeId,
                            @inp_iUserTypeCodeId = m_objRoleMasterDTO.UserTypeCodeId,
                            @inp_iIsDefault      = (m_objRoleMasterDTO.IsDefault ? 1 : 0),
                            @inp_iLoggedInUserId = nLoggedInUserId,
                            @out_nReturnValue    = nout_nReturnValue,
                            @out_nSQLErrCode     = nout_nSQLErrCode,
                            @out_sSQLErrMessage  = sout_sSQLErrMessage,
                        }).SingleOrDefault <RoleMasterDTO>();

                        #region Error Values
                        if (Convert.ToInt32(nout_nReturnValue.Value) != 0)
                        {
                            Exception e = new Exception();
                            out_nReturnValue = Convert.ToInt32(nout_nReturnValue.Value);
                            string sReturnValue = sLookUpPrefix + out_nReturnValue;
                            e.Data[0] = sReturnValue;
                            if (nout_nSQLErrCode.Value != System.DBNull.Value)
                            {
                                out_nSQLErrCode = Convert.ToInt32(nout_nSQLErrCode.Value);
                                e.Data[1]       = out_nSQLErrCode;
                            }
                            if (sout_sSQLErrMessage.Value != System.DBNull.Value)
                            {
                                out_sSQLErrMessage = Convert.ToString(sout_sSQLErrMessage.Value);
                                e.Data[2]          = out_sSQLErrMessage;
                            }
                            Exception ex = new Exception(db.LastSQL.ToString(), e);
                            throw ex;
                        }
                        else
                        {
                            scope.Complete();
                            return(res);
                        }
                        #endregion Error Values
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
            }
        }
Esempio n. 5
0
        public IEnumerable <RoleMasterDTO> GetList(RoleMasterDTO m_objRoleMasterDTO, string sConnectionString)
        {
            #region Paramters
            int    out_nReturnValue;
            int    out_nSQLErrCode;
            string out_sSQLErrMessage;
            #endregion Paramters
            try
            {
                #region Out Paramter
                var nout_nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
                nout_nReturnValue.Direction = System.Data.ParameterDirection.Output;
                nout_nReturnValue.Value     = 0;
                var nout_nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
                nout_nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
                nout_nSQLErrCode.Value     = 0;
                var sout_sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.NVarChar);
                sout_sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
                sout_sSQLErrMessage.Value     = string.Empty;
                #endregion Out Paramter

                using (var db = new PetaPoco.Database(sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    var res = db.Query <RoleMasterDTO>("exec st_usr_RoleMasterList @inp_iRoleId,@inp_sRoleName,@inp_sDescription,@inp_iStatusCodeId,@inp_sLandingPageURL,@inp_iUserTypeCodeId,@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                       new
                    {
                        @inp_iRoleId         = m_objRoleMasterDTO.RoleId,
                        @inp_sRoleName       = m_objRoleMasterDTO.RoleName,
                        @inp_sDescription    = m_objRoleMasterDTO.Description,
                        @inp_iStatusCodeId   = m_objRoleMasterDTO.StatusCodeId,
                        @inp_iUserTypeCodeId = m_objRoleMasterDTO.UserTypeCodeId,
                    }).ToList <RoleMasterDTO>();

                    #region Error Values
                    if (Convert.ToInt32(nout_nReturnValue.Value) != 0)
                    {
                        Exception e = new Exception();
                        out_nReturnValue = Convert.ToInt32(nout_nReturnValue.Value);
                        e.Data[0]        = out_nReturnValue;
                        if (nout_nSQLErrCode.Value != System.DBNull.Value)
                        {
                            out_nSQLErrCode = Convert.ToInt32(nout_nSQLErrCode.Value);
                            e.Data[1]       = out_nSQLErrCode;
                        }
                        if (sout_sSQLErrMessage.Value != System.DBNull.Value)
                        {
                            out_sSQLErrMessage = Convert.ToString(sout_sSQLErrMessage.Value);
                            e.Data[2]          = out_sSQLErrMessage;
                        }
                        Exception ex = new Exception(db.LastCommand.ToString(), e);
                        throw ex;
                    }
                    else
                    {
                        return(res);
                    }
                    #endregion Error Values
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
            }
        }