Exemplo n.º 1
0
        public ActionProfileResult List(bool?activeList)
        {
            try
            {
                BSL.ActionProfileService service = new BSL.ActionProfileService();
                var lists = service.List(activeList);

                var sr = new ActionProfileResult
                {
                    IsSuccess          = true,
                    ListActionProfiles = lists,
                };
                return(sr);
            }
            catch (Exception ex)
            {
                new RMSWebException(this, "0500", "List failed. " + ex.Message, ex, true);

                var sr = new ActionProfileResult
                {
                    IsSuccess    = false,
                    ErrorMessage = "List errors. " + ex.Message
                };
                return(sr);
            }
        }
Exemplo n.º 2
0
        public ActionProfileResult Get(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("ActionProfileID");
            }

            try
            {
                using (var db = new MyDbContext())
                {
                    db.Configuration.ProxyCreationEnabled = false;
                    db.Configuration.LazyLoadingEnabled   = false;

                    RmsActionProfile actionProfile = db.RmsActionProfiles.Find(id);

                    var sr = new ActionProfileResult
                    {
                        IsSuccess     = true,
                        ActionProfile = actionProfile,
                    };
                    return(sr);
                }
            }
            catch (Exception ex)
            {
                new RMSWebException(this, "0500", "Get failed. " + ex.Message, ex, true);

                var sr = new ActionProfileResult
                {
                    IsSuccess    = false,
                    ErrorMessage = ex.Message
                };
                return(sr);
            }
        }
Exemplo n.º 3
0
        public ActionProfileResult Search(JQueryDataTableParamModel param, string txtActionProfile, string txtEmail, string txtSms)
        {
            List <RmsActionProfile> listRmsActionProfile = new List <RmsActionProfile>();

            SqlParameter[] parameters = new SqlParameter[8];

            try
            {
                using (var db = new MyDbContext())
                {
                    SqlParameter p1;
                    SqlParameter p2;
                    SqlParameter p3;

                    if (String.IsNullOrEmpty(txtActionProfile))
                    {
                        p1 = new SqlParameter("ActionProfileName", DBNull.Value);
                    }
                    else
                    {
                        p1 = new SqlParameter("ActionProfileName", txtActionProfile);
                    }

                    if (String.IsNullOrEmpty(txtEmail))
                    {
                        p2 = new SqlParameter("Email", DBNull.Value);
                    }
                    else
                    {
                        p2 = new SqlParameter("Email", txtEmail);
                    }

                    if (String.IsNullOrEmpty(txtSms))
                    {
                        p3 = new SqlParameter("Sms", DBNull.Value);
                    }
                    else
                    {
                        p3 = new SqlParameter("Sms", txtSms);
                    }
                    SqlParameter p4 = new SqlParameter("PageNbr", DBNull.Value);
                    SqlParameter p5 = new SqlParameter("PageSize", param.iDisplayLength);
                    SqlParameter p6 = new SqlParameter("FirstRec", param.iDisplayStart);
                    SqlParameter p7 = new SqlParameter("SortCol", param.iSortColumn);
                    SqlParameter p8 = new SqlParameter("TotalRecords", SqlDbType.Int);
                    p8.Direction = ParameterDirection.Output;

                    parameters[0] = p1;
                    parameters[1] = p2;
                    parameters[2] = p3;
                    parameters[3] = p4;
                    parameters[4] = p5;
                    parameters[5] = p6;
                    parameters[6] = p7;
                    parameters[7] = p8;

                    db.Configuration.ProxyCreationEnabled = false;
                    //db.Configuration.LazyLoadingEnabled = false;

                    var listOfType = db.Database.SqlQuery <RmsActionProfile>("RMS_SearchActionProfile " +
                                                                             "@ActionProfileName, @Email, @Sms, @PageNbr, @PageSize, @FirstRec, @SortCol, @TotalRecords OUTPUT"
                                                                             , parameters);

                    listRmsActionProfile = new List <RmsActionProfile>(listOfType.ToList());

                    ActionProfileResult sr = new ActionProfileResult
                    {
                        IsSuccess          = true,
                        ListActionProfiles = listRmsActionProfile,
                        TotalRecords       = (int)parameters[7].Value
                    };
                    return(sr);
                }
            }
            catch (Exception ex)
            {
                new RMSWebException(this, "0500", "Search failed. " + ex.Message, ex, true);

                return(new ActionProfileResult
                {
                    IsSuccess = false,
                    ErrorMessage = ex.Message
                });
            }
        }