Ejemplo n.º 1
0
        public IEnumerable <MessageCountEntity> GetMessageStats(string interval, string startDate = "", string endDate = "", string goBackBy = "", string providerType = "all")
        {
            var results = _icountMessage.GetMessageStats(interval, startDate, endDate, goBackBy, providerType);

            return(results.Select(i => new MessageCountEntity
            {
                total_message = i.total_message,
                date = i.date,
                message_states = i.message_states
            }));
        }
        public IEnumerable <MessageCountEntity> GetMessageStats(string interval, string startDate = "", string endDate = "", string goBackBy = "", string mustNotMath = "", string providerType = "all")
        {
            var l = User.Identity;

            //try
            //{

            if (interval.Equals("") || interval.Equals(null))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent(string.Format("Response: 'Invalid request: interval can not be null'")),
                    ReasonPhrase = "Reason:'Interval can not be null...'"
                };
                throw new HttpResponseException(resp);
            }
            //DateTime startD = Convert.ToDateTime(startDate);
            //    DateTime endD = Convert.ToDateTime(endDate);
            //    if(startD>endD)
            //    {
            //        var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
            //        {
            //            Content = new StringContent(string.Format("Response: 'Invalid date range'")),
            //            ReasonPhrase = "Reason:'The end date can on be a date before the start date'"
            //        };
            //        throw new HttpResponseException(resp);
            //    }

            //}
            //catch (Exception)
            //{
            //    var errorCause = new HttpResponseMessage(HttpStatusCode.NotFound)
            //    {
            //        Content = new StringContent(string.Format("Invalid Invalid request, Make sure that you inputs are correct, the required field is not null/empty and parameter name are correct")),
            //        ReasonPhrase = "The end date can on be a date before the start date"
            //    };
            //    throw new HttpResponseException(HttpStatusCode.NotFound);
            //}

            var results = _icountMessage.GetMessageStats(interval, startDate, endDate, goBackBy, mustNotMath, providerType);

            return(results.Select(i => new MessageCountEntity
            {
                total_message = i.total_message,
                date = i.date,
                message_states = i.message_states
            }));
        }