//Assemble single project
        public FinalReport AssembleBreakingProjectByMonth(ReportParametrsFromToProjectIdJson parametres)
        {
            var result = new FinalReport();

            UnitOfWork       uow              = new UnitOfWork();
            var              currentUser      = new UserHelper().GetCurrent();
            TimeSheetManager TimeSheetManager = new TimeSheetManager(uow);


            var from        = DateUtility.GetMiladiDate(parametres.FromDate);
            var to          = DateUtility.GetMiladiDate(parametres.ToDate);
            var currentDate = from;
            var workHours   = TimeSheetManager.GetByProjectID
                                  (parametres.ProjectId, from, to).ToList();

            if (workHours.Count() > 0)
            {
                foreach (var group in workHours.GroupBy(x => x.TaskID))
                {
                    var row = new ReportRow();
                    row.ID    = group.First().TaskID;
                    row.Title = group.First().Task.Title;
                    result.Rowes.Add(row);
                }
            }

            var SumTotal = new ReportRow();

            SumTotal.ID    = Guid.NewGuid();
            SumTotal.Title = "جمع کل";
            result.Rowes.Add(SumTotal);


            while (currentDate.Date <= to)
            {
                var firstDayOfMonth = DateUtility.GetMiladiDate(DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate) + "/" + "1");
                var day             = "30";
                if (DateUtility.GetPersianMonth(currentDate) < 7)
                {
                    day = "31";
                }
                var LastDayOfMonth = DateUtility.GetMiladiDate(DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate) + "/" + day);
                var field          = new Field();
                field.ID    = Guid.NewGuid();
                field.Title = DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate);
                result.Fields.Add(field);
                double workhours = 0;


                foreach (var row in result.Rowes)
                {
                    if (row.Title == "جمع کل")
                    {
                        var sumWorkHour = workHours.Where(x => x.Date.Date <= LastDayOfMonth && x.Date.Date >= firstDayOfMonth).Sum(x => x.Hours);
                        workhours = sumWorkHour;
                        var fieldValuesumWorkHour = new FieldValue();
                        fieldValuesumWorkHour.FieldId = field.ID;
                        fieldValuesumWorkHour.RowId   = row.ID;
                        fieldValuesumWorkHour.Value   = DateUtility.ConvertToTimeSpan(sumWorkHour);
                        row.Values.Add(fieldValuesumWorkHour);
                    }

                    else
                    {
                        var value      = workHours.Where(x => x.TaskID == row.ID && x.Date.Date <= LastDayOfMonth && x.Date.Date >= firstDayOfMonth).Sum(x => x.Hours);
                        var fieldValue = new FieldValue();
                        fieldValue.FieldId = field.ID;
                        fieldValue.RowId   = row.ID;
                        fieldValue.Value   = DateUtility.ConvertToTimeSpan(value);
                        row.Values.Add(fieldValue);
                    }
                }

                currentDate = LastDayOfMonth.AddDays(1).Date;
            }
            var Aggregation = new Field();

            Aggregation.Title = "جمع کل";
            Aggregation.ID    = Guid.NewGuid();
            result.Fields.Add(Aggregation);
            double Alltotalsum = 0;

            foreach (var row in result.Rowes)
            {
                var sum        = workHours.Where(x => x.TaskID == row.ID).Sum(y => y.Hours);
                var fieldvalue = new FieldValue();
                fieldvalue.CalculativeValue = sum;
                fieldvalue.FieldId          = Guid.NewGuid();
                fieldvalue.RowId            = row.ID;
                fieldvalue.Value            = DateUtility.ConvertToTimeSpan(sum);
                row.Values.Add(fieldvalue);
                Alltotalsum += sum;
            }


            result.Rowes[result.Rowes.Count() - 1].Values[result.Rowes[result.Rowes.Count() - 1].
                                                          Values.Count() - 1].Value = DateUtility.ConvertToTimeSpan(Alltotalsum);



            result.HeaderTitle      = "گزارش یک  پروژه به تفکیک ماه";
            result.FirstColumnTitle = "عنوان وظیفه";
            return(result);
        }
        //Assemble Bounch of projects
        public FinalReport AssembleBreakingProjectsByMonth(ReportParametersFromToJson parametres)
        {
            var result = new FinalReport();

            UnitOfWork       uow              = new UnitOfWork();
            var              currentUser      = new UserHelper().GetCurrent();
            TimeSheetManager TimeSheetManager = new TimeSheetManager(uow);
            var              workHours        = TimeSheetManager.GetWorkHoursByUser
                                                    (currentUser, DateUtility.GetMiladiDate(parametres.FromDate), DateUtility.GetMiladiDate(parametres.ToDate)).ToList();


            var from        = DateUtility.GetMiladiDate(parametres.FromDate);
            var to          = DateUtility.GetMiladiDate(parametres.ToDate);
            var currentDate = from;

            foreach (var group in workHours.GroupBy(x => x.ProjectId))
            {
                var row = new ReportRow();
                row.ID    = group.First().ProjectId;
                row.Title = group.First().Project.Title;
                result.Rowes.Add(row);
            }

            var SumTotal = new ReportRow();

            SumTotal.ID    = Guid.NewGuid();
            SumTotal.Title = "جمع کل کارکرد";
            result.Rowes.Add(SumTotal);
            var sumPresenceHours = new ReportRow();

            sumPresenceHours.ID    = Guid.NewGuid();
            sumPresenceHours.Title = "جمع کل حضور";
            result.Rowes.Add(sumPresenceHours);
            var sumDifference = new ReportRow();

            sumDifference.ID    = Guid.NewGuid();
            sumDifference.Title = "اختلاف";
            result.Rowes.Add(sumDifference);


            while (currentDate.Date <= to)
            {
                var firstDayOfMonth = DateUtility.GetMiladiDate(DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate) + "/" + "1");
                var day             = "30";
                if (DateUtility.GetPersianMonth(currentDate) < 7)
                {
                    day = "31";
                }
                var LastDayOfMonth = DateUtility.GetMiladiDate(DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate) + "/" + day);
                var field          = new Field();
                field.ID    = Guid.NewGuid();
                field.Title = DateUtility.GetPersianYear(currentDate) + "/" + DateUtility.GetPersianMonth(currentDate);
                result.Fields.Add(field);
                double workhours     = 0;
                double presencehours = 0;

                foreach (var row in result.Rowes)
                {
                    if (row.Title == "جمع کل کارکرد")
                    {
                        var sumWorkHour = workHours.Where(x => x.Date.Date <= LastDayOfMonth && x.Date.Date >= firstDayOfMonth).Sum(x => x.Hours);
                        workhours = sumWorkHour;
                        var fieldValuesumWorkHour = new FieldValue();
                        fieldValuesumWorkHour.FieldId = field.ID;
                        fieldValuesumWorkHour.RowId   = row.ID;
                        fieldValuesumWorkHour.Value   = DateUtility.ConvertToTimeSpan(sumWorkHour);
                        row.Values.Add(fieldValuesumWorkHour);
                    }
                    else if (row.Title == "جمع کل حضور")
                    {
                        var sumPresenceHour = TimeSheetManager.GetPresHoursByUser(currentUser, firstDayOfMonth, LastDayOfMonth).Sum(x => x.Hours);
                        presencehours = sumPresenceHour;
                        var fieldValuesumPresenceHour = new FieldValue();
                        fieldValuesumPresenceHour.FieldId = field.ID;
                        fieldValuesumPresenceHour.RowId   = row.ID;
                        fieldValuesumPresenceHour.Value   = DateUtility.ConvertToTimeSpan(sumPresenceHour);
                        row.Values.Add(fieldValuesumPresenceHour);
                    }
                    else if (row.Title == "اختلاف")
                    {
                        var sumdifference = presencehours - workhours;;

                        var fieldValuesumdifference = new FieldValue();
                        fieldValuesumdifference.FieldId = field.ID;
                        fieldValuesumdifference.RowId   = row.ID;
                        fieldValuesumdifference.Value   = DateUtility.ConvertToTimeSpan(sumdifference);
                        row.Values.Add(fieldValuesumdifference);
                    }
                    else
                    {
                        var value      = workHours.Where(x => x.ProjectId == row.ID && x.Date.Date <= LastDayOfMonth && x.Date.Date >= firstDayOfMonth).Sum(x => x.Hours);
                        var fieldValue = new FieldValue();
                        fieldValue.FieldId = field.ID;
                        fieldValue.RowId   = row.ID;
                        fieldValue.Value   = DateUtility.ConvertToTimeSpan(value);
                        row.Values.Add(fieldValue);
                    }
                }



                currentDate = LastDayOfMonth.AddDays(1).Date;
            }
            var Aggregation = new Field();

            Aggregation.Title = "مجموع";
            Aggregation.ID    = Guid.NewGuid();
            result.Fields.Add(Aggregation);

            foreach (var row in result.Rowes)
            {
                var sum       = workHours.Where(x => x.ProjectId == row.ID).Sum(y => y.Hours);
                var fildvalue = new FieldValue();
                fildvalue.FieldId = Guid.NewGuid();
                fildvalue.RowId   = row.ID;
                fildvalue.Value   = DateUtility.ConvertToTimeSpan(sum);
                row.Values.Add(fildvalue);
            }



            result.HeaderTitle      = "گزارش پروژه ها به تفکیک ماه";
            result.FirstColumnTitle = "عنوان پروژه";
            return(result);
        }