using C1.Web.Mvc;
using C1.Web.Mvc.Serialization;
using DashboardModel;
using System.Collections;
using System.Collections.Generic;
using System.Web.Mvc;

namespace DashboardDemo.Controllers
{
    public partial class HomeController
    {
        public ActionResult Analysis()
        {            
            if (DataService.DateRange != null && DataService.DateRange.Start.Equals(DataService.DateRange.End))
                DataService.DateRange = DataService.fullRange;

            ViewBag.RegionSales = DataService.GetCategoryRegionWiseSales();
            ViewBag.OpportunityItemList = DataService.OpportunityItemList;
            ViewBag.ProductWiseSaleCollection = DataService.ProductWiseSaleCollection;
            ViewBag.DateSaleList = DataService.DateSaleList;
            return View();
        }

        public ActionResult GetAnalysisData()
        {
            UpdateDateRange();

            ArrayList respone = new ArrayList();
            List<ProductsWiseSaleItem> categoryRegionSale = DataService.GetCategoryRegionWiseSales();
            respone.Add(CollectionViewHelper.Read<ProductsWiseSaleItem>(new CollectionViewRequest<ProductsWiseSaleItem>(), categoryRegionSale));

            var opportunities = DataService.OpportunityItemList;
            respone.Add(CollectionViewHelper.Read<Opportunity>(new CollectionViewRequest<Opportunity>(), opportunities));

            return this.C1Json(respone);
        }
    }
}
