Beispiel #1
0
        public StatusDTO <UserEntitlementDTO> InsertUserEntitlement(UserEntitlementDTO data)
        {
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "UserEntitlementMap";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Connection  = dbSvc.GetConnection() as MySqlConnection;

                    command.Parameters.Add("@UserMasterId1", MySqlDbType.String).Value = data.UserDetails.UserMasterId;
                    command.Parameters.Add("@UserRoleId1", MySqlDbType.String).Value   = data.RoleDetails.UserRoleId;

                    MySqlDataReader rdr = command.ExecuteReader(CommandBehavior.CloseConnection);
                    _dtData = new DataTable();
                    _dtData.Load(rdr);
                    StatusDTO <UserEntitlementDTO> status = new StatusDTO <UserEntitlementDTO>();
                    return(status);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
        }
Beispiel #2
0
        public StatusDTO <UserEntitlementDTO> UpdateUserEntitlement(UserEntitlementDTO data)
        {
            StatusDTO <UserEntitlementDTO> status = new StatusDTO <UserEntitlementDTO>();

            status.IsSuccess = false;
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "UPDATE userentitlement set UserRoleId=@UserRoleId1 WHERE UserEntitleMentId=@UserEntitleMentId";
                    command.Parameters.Add("@UserEntitleMentId", MySqlDbType.Int32).Value = data.RowId;
                    command.Parameters.Add("@UserRoleId1", MySqlDbType.Int32).Value       = data.RoleDetails.UserRoleId;

                    command.Connection = dbSvc.GetConnection() as MySqlConnection;

                    if (command.ExecuteNonQuery() > 0)
                    {
                        status.IsSuccess = true;
                    }
                    return(status);
                }
                catch (Exception exp)
                {
                    _logger.Log(exp);
                    throw exp;
                }
            }
        }
 public JsonResult DeleteUserEntitlement(UserEntitlementDTO uTrans)
 {
     if (_userSvc.DeleteUserEntitlement(uTrans).IsSuccess)
     {
         return(Json(new { status = true, message = "Deleted successfully." }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { status = false, message = "Delete failed." }, JsonRequestBehavior.AllowGet));
 }
Beispiel #4
0
        //To get user entitlementlist
        public List <UserEntitlementDTO> GetUserEntitlement(int userMasterId)
        {
            using (IDbSvc dbSvc = new DbSvc(_configSvc))
            {
                try
                {
                    dbSvc.OpenConnection();
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = "SELECT UserEntitleMentId, UserMasterId, UserRoleId FROM userentitlement WHERE UserMasterId=@umId";
                    command.Parameters.Add("@umId", MySqlDbType.Int32).Value = userMasterId;
                    command.Connection = dbSvc.GetConnection() as MySqlConnection;

                    MySqlDataAdapter mDa = new MySqlDataAdapter(command);
                    _dtData = new DataTable();
                    mDa.Fill(_dtData);
                    List <UserEntitlementDTO> lstUEnt = null;
                    if (_dtData != null && _dtData.Rows.Count > 0)
                    {
                        lstUEnt = new List <UserEntitlementDTO>();
                        UserEntitlementDTO uEntDTO = null;
                        foreach (DataRow dr in _dtData.Rows)
                        {
                            uEntDTO             = new UserEntitlementDTO();
                            uEntDTO.UserDetails = new UserMasterDTO();
                            uEntDTO.RoleDetails = new EntitlementDTO();

                            uEntDTO.RowId = (int)dr["UserEntitleMentId"];
                            uEntDTO.UserDetails.UserMasterId = (int)dr["UserMasterId"];
                            uEntDTO.RoleDetails.UserRoleId   = (int)dr["UserRoleId"];

                            lstUEnt.Add(uEntDTO);
                        }
                    }
                    return(lstUEnt);
                }
                catch (Exception exp)
                {
                    _logger.Log(exp);
                    throw exp;
                }
            }
        }