예제 #1
0
        public ResultModel <List <MagfaModel> > GLNsCount(ServicesReportModel model)
        {
            try
            {
                var DX = new EntitiesContext();

                var dt        = new DataTable();
                var _FromDate = new DateTime?();
                var _ToDate   = new DateTime?();

                if (model != null && model.FromDate != null && model.FromDate != "")
                {
                    _FromDate = Convert.ToDateTime(Convert.ToDateTime(_FromDate).ToShortDateString());
                }
                if (model != null && model.FromDate != null && model.FromDate != "")
                {
                    _ToDate = Convert.ToDateTime(Convert.ToDateTime(_ToDate).ToShortDateString());
                }

                dt = DX.ExecuteStoredProcedure(DX, "GLNsCountReport", new[] {
                    new SqlParameter("@FromDate", _FromDate),
                    //new SqlParameter("@StatusID", model.StatusID),
                    new SqlParameter("@ToDate", _ToDate)
                });

                if (dt.Rows.Count == 0)
                {
                    return(new ResultModel <List <MagfaModel> >
                    {
                        Succeeded = false,
                        Message = "اطلاعات موجود نمی باشد."
                    });
                }

                var query = dt.Rows.OfType <DataRow>().Select(x => new MagfaModel
                {
                    Title             = x["Title"].ToString(),
                    CountGLN          = x["CountGLN"] != null ? Convert.ToInt32(x["CountGLN"]) : 0,
                    ExternalCodeCount = Convert.ToInt32(x["ExternalCodeCount"]),
                    InternalCodeCount = Convert.ToInt32(x["InternalCodeCount"])
                                        //            RecpayID = (int)x["ID"],
                                        //            TypeTitle = x["TypeTitle"].ToString(),
                                        //            RecpayPrice = (decimal)x["RecpayPrice"],
                                        //            RecpayDate = (DateTime)x["RecpayDate"],
                                        //            RegisterSystemDate = (DateTime)x["RegisterSystemDate"],
                                        //            OwnerUserDisplayName = x["OwnerUserDisplayName"].ToString(),
                                        //            Status = Convert.ToInt32(x["Status"]),
                                        //            RecPayConfrimDate = Convert.IsDBNull(x["RecPayConfrimDate"]) ? (DateTime?)null : (DateTime)x["RecPayConfrimDate"],
                }).ToList();

                return(new ResultModel <List <MagfaModel> >
                {
                    Succeeded = true,
                    Result = query
                });
            }
            catch (Exception x)
            {
                return(new ResultModel <List <MagfaModel> >
                {
                    Succeeded = false,
                    Message = "خطا در عملیات - لطفا دوباره تلاش نمائید."
                });
            }
        }