Example #1
0
 public async Task <IActionResult> ReportUpload(int id)
 {
     try
     {
         using (BillingReportContext context = new BillingReportContext())
         {
             var report         = context.TblReportSummery.Where(i => i.ReportId == id).FirstOrDefault();
             var reportSummmary = new ReportSummery
             {
                 clientName  = report.ClientName,
                 projectName = report.ProjectName,
                 projectType = report.ProjectType
             };
             var mail = report.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
             if (report.ProjectType == "Week")
             {
                 EmailHelper.ReportUploaded(mail, emailSender, "", reportSummmary);
             }
             else
             {
                 EmailHelper.ReportSubmitted(mail, emailSender, "", reportSummmary);
             }
             await context.SaveChangesAsync();
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int SaveReportDetails([FromBody] Report reportDetail)
        {
            using (BillingReportContext context = new BillingReportContext())
            {
                TblReportSummery reportSummery = new TblReportSummery();
                reportSummery.ApprovedBy      = null;
                reportSummery.ApprovedDate    = null;
                reportSummery.ClientName      = reportDetail.ClientName;
                reportSummery.CreatedBy       = reportDetail.CreatedBy;
                reportSummery.CreatedByEmail  = reportDetail.CreatedByEmail;
                reportSummery.CreatedDate     = DateTime.Now;
                reportSummery.IsApproved      = false;
                reportSummery.LastUpdatedBy   = null;
                reportSummery.LastUpdatedDate = null;
                reportSummery.ProjectEndDate  = DateTime.Now.AddDays(90);
                reportSummery.ProjectName     = reportDetail.ProjectName;
                reportSummery.ProjectType     = reportDetail.ProjectType;
                reportSummery.ReportStartDate = reportDetail.ReportStartDate;
                reportSummery.ReportEndDate   = reportDetail.ReportEndDate;
                reportSummery.Remark          = null;
                reportSummery.ReportStatus    = reportDetail.ReportStatus;
                reportSummery.Type            = reportDetail.Type;

                context.Add(reportSummery);
                context.SaveChanges();
                int id = reportSummery.ReportId;
                return(id);
            }
        }
Example #3
0
 public async Task <IActionResult> ChangeStatusReport([FromRoute] int id)
 {
     using (BillingReportContext context = new BillingReportContext())
     {
         var report = context.TblReportSummery.Where(i => i.ReportId == id).FirstOrDefault();
         report.ReportStatus = Convert.ToInt32(ReportStatus.Uploaded);
         context.TblReportSummery.Update(report);
         await context.SaveChangesAsync();
     }
     return(Ok());
 }
Example #4
0
 public async Task <IActionResult> RejectReport([FromRoute] int id, [FromRoute] string remark)
 {
     using (BillingReportContext context = new BillingReportContext())
     {
         var report = context.TblReportSummery.Where(i => i.ReportId == id).FirstOrDefault();
         report.ReportStatus = Convert.ToInt32(ReportStatus.Rejected);
         report.Remark       = remark;
         context.TblReportSummery.Update(report);
         var mail = report.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
         EmailHelper.ReportRejected(mail, emailSender, "", remark, report);
         await context.SaveChangesAsync();
     }
     return(Ok());
 }
Example #5
0
 public IEnumerable <ActivityDetails> getActivityDetails(int id)
 {
     try
     {
         using (BillingReportContext context = new BillingReportContext())
         {
             return(context.TblReportActivity.Where(x => x.ReportId == id).Select(x => new ActivityDetails()
             {
                 milestones = x.Milestones,
                 eta = Convert.ToInt32(x.Eta)
             }
                                                                                  ).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #6
0
 public IEnumerable <CRDetails> getCRDetails(int id)
 {
     try
     {
         using (BillingReportContext context = new BillingReportContext())
         {
             return(context.TblReportCr.Where(x => x.ReportId == id).Select(x => new CRDetails()
             {
                 crName = x.CrName,
                 estimateHrs = (int)x.EstimateHrs,
                 actualHrs = (int)x.ActualHrs,
                 status = Convert.ToString(x.Status)
             }
                                                                            ).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #7
0
        public ReportSummery getReportSummeryDetails(int id)
        {
            try
            {
                using (BillingReportContext context = new BillingReportContext())
                {
                    ReportSummery reportSummery = new ReportSummery();

                    reportSummery = (from RS in context.TblReportSummery
                                     join RSD in context.TblReportSummeryDetails on RS.ReportId equals RSD.ReportId
                                     where RS.ReportId == id
                                     select new ReportSummery
                    {
                        clientName = RS.ClientName,
                        projectName = RS.ProjectName,
                        projectType = RS.ProjectType,
                        accomp = RSD.Accomplishments,
                        clientAwtInfo = RSD.ClientAwtInfo,
                        onShoreTotalHrs = (int)RSD.OnshoreTotalHrs,
                        onShoreHrsTillLastWeek = (int)RSD.OnshoreLastWeekHrs,
                        onShoreHrsCurrentWeek = (int)RSD.OnshoreCurrentWeekHrs,
                        offShoreTotalHrs = (int)RSD.OnshoreTotalHrs,
                        offShoreHrsTillLastWeek = (int)RSD.OffshoreLastWeekHrs,
                        offShoreHrsCurrentWeek = (int)RSD.OffshoreCurrentWeekHrs,
                        notes = RSD.Notes,
                        CreatedBy = RS.CreatedBy,
                        CreatedByEmail = RS.CreatedByEmail,
                        ReportStartDate = RS.ReportStartDate,
                        ReportEndDate = RS.ReportEndDate,
                        Type = RS.Type
                    }).SingleOrDefault();

                    return(reportSummery);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> GetReport([FromRoute] string role, [FromRoute] int reportStatus, [FromRoute] string userEmail)
        {
            var result = new List <ReportList>();

            using (BillingReportContext context = new BillingReportContext())
            {
                if (role == "TL")
                {
                    if (reportStatus == 0) // Saved
                    {
                        result = (from reportSummary in context.TblReportSummery
                                  where (reportSummary.ReportStatus == Convert.ToInt32(ReportStatus.Saved)) &&
                                  reportSummary.CreatedByEmail == userEmail
                                  orderby reportSummary.CreatedDate descending
                                  select new ReportList
                        {
                            ReportId = reportSummary.ReportId,
                            ClientName = reportSummary.ClientName,
                            ProjectName = reportSummary.ProjectName,
                            ProjectType = reportSummary.ProjectType,
                            CreatedDate = reportSummary.CreatedDate,
                            ReportStartDate = reportSummary.ReportStartDate,
                            ReportEndDate = reportSummary.ReportEndDate
                        }).ToList();
                    }
                    if (reportStatus == 2) // Rejected
                    {
                        result = (from reportSummary in context.TblReportSummery
                                  where reportSummary.ReportStatus == Convert.ToInt32(ReportStatus.Rejected) &&
                                  reportSummary.CreatedByEmail == userEmail
                                  orderby reportSummary.LastUpdatedDate descending
                                  select new ReportList
                        {
                            ReportId = reportSummary.ReportId,
                            ClientName = reportSummary.ClientName,
                            ProjectName = reportSummary.ProjectName,
                            ProjectType = reportSummary.ProjectType,
                            CreatedDate = reportSummary.CreatedDate,
                            ReportStartDate = reportSummary.ReportStartDate,
                            ReportEndDate = reportSummary.ReportEndDate,
                            Remark = reportSummary.Remark
                        }).ToList();
                    }
                }
                else
                if (role == "Manager")
                {
                    if (reportStatus == 1) // Submitted and Rejected
                    {
                        result = (from reportSummary in context.TblReportSummery
                                  where reportSummary.ReportStatus == Convert.ToInt32(ReportStatus.Created)
                                  orderby reportSummary.LastUpdatedDate descending
                                  select new ReportList
                        {
                            ReportId = reportSummary.ReportId,
                            ClientName = reportSummary.ClientName,
                            ProjectName = reportSummary.ProjectName,
                            ProjectType = reportSummary.ProjectType,
                            CreatedDate = reportSummary.CreatedDate,
                            SubmittedBy = reportSummary.CreatedBy,
                            ReportStartDate = reportSummary.ReportStartDate,
                            ReportEndDate = reportSummary.ReportEndDate,
                            Remark = reportSummary.Remark
                        }).ToList();
                    }
                }
            }



            return(Ok(result));
        }
Example #9
0
        public ActionResult draftReportSummery([FromBody] ReportSummery reportSummery)
        {
            try
            {
                if (reportSummery != null)
                {
                    using (BillingReportContext context = new BillingReportContext())
                    {
                        if (reportSummery.id == 0)
                        {
                            TblReportSummery tblReportSummery = new TblReportSummery();
                            tblReportSummery.ClientName      = reportSummery.clientName;
                            tblReportSummery.ProjectName     = reportSummery.projectName;
                            tblReportSummery.ProjectType     = reportSummery.projectType;
                            tblReportSummery.ReportStartDate = reportSummery.ReportStartDate; //Convert.ToDateTime("2019-01-01");
                            tblReportSummery.ProjectEndDate  = DateTime.UtcNow;               //Convert.ToDateTime("2019-01-01");
                            tblReportSummery.CreatedBy       = reportSummery.CreatedBy;
                            tblReportSummery.CreatedDate     = DateTime.Now;
                            tblReportSummery.LastUpdatedBy   = "Admin";
                            tblReportSummery.LastUpdatedDate = DateTime.Now;
                            tblReportSummery.ApprovedBy      = "Admin";
                            tblReportSummery.ApprovedDate    = DateTime.Now;
                            tblReportSummery.Remark          = reportSummery.notes;
                            tblReportSummery.IsApproved      = true;
                            tblReportSummery.ReportStatus    = 0;
                            tblReportSummery.CreatedByEmail  = reportSummery.CreatedByEmail;
                            tblReportSummery.ReportEndDate   = reportSummery.ReportEndDate;
                            tblReportSummery.Type            = reportSummery.Type;

                            context.TblReportSummery.Add(tblReportSummery);
                            context.SaveChanges();

                            var report_id = tblReportSummery.ReportId;

                            TblReportSummeryDetails tblReportSummeryDetails = new TblReportSummeryDetails();

                            tblReportSummeryDetails.ReportId               = report_id;
                            tblReportSummeryDetails.Crid                   = 1;
                            tblReportSummeryDetails.ActivityId             = 1;
                            tblReportSummeryDetails.OnshoreTotalHrs        = reportSummery.onShoreTotalHrs;
                            tblReportSummeryDetails.OnshoreLastWeekHrs     = reportSummery.onShoreHrsTillLastWeek;
                            tblReportSummeryDetails.OnshoreCurrentWeekHrs  = reportSummery.onShoreHrsCurrentWeek;
                            tblReportSummeryDetails.OffShoreTotalHrs       = reportSummery.offShoreTotalHrs;
                            tblReportSummeryDetails.OffshoreLastWeekHrs    = reportSummery.offShoreHrsTillLastWeek;
                            tblReportSummeryDetails.OffshoreCurrentWeekHrs = reportSummery.offShoreHrsCurrentWeek;
                            tblReportSummeryDetails.Accomplishments        = reportSummery.accomp;
                            tblReportSummeryDetails.ClientAwtInfo          = reportSummery.clientAwtInfo;
                            tblReportSummeryDetails.Notes                  = reportSummery.notes;

                            context.TblReportSummeryDetails.Add(tblReportSummeryDetails);
                            context.SaveChanges();

                            foreach (CRDetails cR in reportSummery.crDetails)
                            {
                                TblReportCr tblReportCr = new TblReportCr();

                                tblReportCr.ReportId    = report_id;
                                tblReportCr.CrName      = cR.crName;
                                tblReportCr.ActualHrs   = cR.actualHrs;
                                tblReportCr.EstimateHrs = cR.estimateHrs;
                                tblReportCr.Status      = cR.status;

                                context.TblReportCr.Add(tblReportCr);
                            }
                            context.SaveChanges();

                            foreach (ActivityDetails AD in reportSummery.activityDetails)
                            {
                                TblReportActivity tblReportActivity = new TblReportActivity();

                                tblReportActivity.ReportId   = report_id;
                                tblReportActivity.Milestones = AD.milestones;
                                tblReportActivity.Eta        = AD.eta;

                                context.TblReportActivity.Add(tblReportActivity);
                            }
                            context.SaveChanges();
                            return(Ok(report_id));
                        }
                        else
                        {
                            //code for update

                            TblReportSummery tblReportSummery = context.TblReportSummery.SingleOrDefault(x => x.ReportId == reportSummery.id);

                            if (tblReportSummery != null)
                            {
                                tblReportSummery.ClientName  = reportSummery.clientName;
                                tblReportSummery.ProjectName = reportSummery.projectName;
                                tblReportSummery.ProjectType = reportSummery.projectType;
                                //tblReportSummery.ReportStartDate = Convert.ToDateTime("2019-01-01");
                                //tblReportSummery.ProjectEndDate = Convert.ToDateTime("2019-01-01");
                                //tblReportSummery.CreatedBy = "UpdateAdmin";
                                //tblReportSummery.CreatedDate = DateTime.Now;
                                tblReportSummery.LastUpdatedBy   = reportSummery.CreatedBy;
                                tblReportSummery.LastUpdatedDate = DateTime.Now;
                                tblReportSummery.ApprovedBy      = "UpdateAdmin";
                                tblReportSummery.ApprovedDate    = DateTime.Now;
                                tblReportSummery.Remark          = reportSummery.notes;
                                tblReportSummery.IsApproved      = true;
                                tblReportSummery.ReportStatus    = 0;

                                context.SaveChanges();
                            }

                            TblReportSummeryDetails tblReportSummeryDetails = context.TblReportSummeryDetails.SingleOrDefault(x => x.ReportId == reportSummery.id);

                            if (tblReportSummeryDetails != null)
                            {
                                ///tblReportSummeryDetails.ReportId = report_id;
                                tblReportSummeryDetails.Crid                   = 1;
                                tblReportSummeryDetails.ActivityId             = 1;
                                tblReportSummeryDetails.OnshoreTotalHrs        = reportSummery.onShoreTotalHrs;
                                tblReportSummeryDetails.OnshoreLastWeekHrs     = reportSummery.onShoreHrsTillLastWeek;
                                tblReportSummeryDetails.OnshoreCurrentWeekHrs  = reportSummery.onShoreHrsCurrentWeek;
                                tblReportSummeryDetails.OffShoreTotalHrs       = reportSummery.offShoreTotalHrs;
                                tblReportSummeryDetails.OffshoreLastWeekHrs    = reportSummery.offShoreHrsTillLastWeek;
                                tblReportSummeryDetails.OffshoreCurrentWeekHrs = reportSummery.offShoreHrsCurrentWeek;
                                tblReportSummeryDetails.Accomplishments        = reportSummery.accomp;
                                tblReportSummeryDetails.ClientAwtInfo          = reportSummery.clientAwtInfo;
                                tblReportSummeryDetails.Notes                  = reportSummery.notes;

                                context.SaveChanges();
                            }

                            //delete existing entry
                            // db.ProRel.RemoveRange(db.ProRel.Where(c => c.ProjectId == Project_id));
                            context.TblReportCr.RemoveRange(context.TblReportCr.Where(x => x.ReportId == reportSummery.id));

                            foreach (CRDetails cR in reportSummery.crDetails)
                            {
                                TblReportCr tblReportCr = new TblReportCr();

                                tblReportCr.ReportId    = reportSummery.id;
                                tblReportCr.CrName      = cR.crName;
                                tblReportCr.ActualHrs   = cR.actualHrs;
                                tblReportCr.EstimateHrs = cR.estimateHrs;
                                tblReportCr.Status      = cR.status;

                                context.TblReportCr.Add(tblReportCr);
                            }
                            context.SaveChanges();

                            //delete existing entry
                            context.TblReportActivity.RemoveRange(context.TblReportActivity.Where(x => x.ReportId == reportSummery.id));

                            foreach (ActivityDetails AD in reportSummery.activityDetails)
                            {
                                TblReportActivity tblReportActivity = new TblReportActivity();

                                tblReportActivity.ReportId   = reportSummery.id;
                                tblReportActivity.Milestones = AD.milestones;
                                tblReportActivity.Eta        = AD.eta;

                                context.TblReportActivity.Add(tblReportActivity);
                            }
                            context.SaveChanges();

                            return(Ok(reportSummery.id));
                        }
                    }
                }
                else
                {
                    return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status406NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #10
0
        public ActionResult saveReportSummery([FromBody] ReportSummery reportSummery)
        {
            try
            {
                using (BillingReportContext context = new BillingReportContext())
                {
                    if (reportSummery.id == 0)
                    {
                        TblReportSummery tblReportSummery = new TblReportSummery();

                        tblReportSummery.ClientName      = reportSummery.clientName;
                        tblReportSummery.ProjectName     = reportSummery.projectName;
                        tblReportSummery.ProjectType     = reportSummery.projectType;
                        tblReportSummery.ReportStartDate = reportSummery.ReportStartDate; //Convert.ToDateTime("2019-01-01");
                        tblReportSummery.ProjectEndDate  = DateTime.UtcNow;               //Convert.ToDateTime("2019-01-01");
                        tblReportSummery.CreatedBy       = reportSummery.CreatedBy;
                        tblReportSummery.CreatedDate     = DateTime.Now;
                        tblReportSummery.LastUpdatedBy   = "Admin";
                        tblReportSummery.LastUpdatedDate = DateTime.Now;
                        tblReportSummery.ApprovedBy      = "Admin";
                        tblReportSummery.ApprovedDate    = DateTime.Now;
                        tblReportSummery.Remark          = reportSummery.notes;
                        tblReportSummery.IsApproved      = true;
                        tblReportSummery.ReportStatus    = reportSummery.projectType == "Week" ? Convert.ToInt32(ReportStatus.Uploaded) : Convert.ToInt32(ReportStatus.Created);
                        tblReportSummery.CreatedByEmail  = reportSummery.CreatedByEmail;
                        tblReportSummery.ReportEndDate   = reportSummery.ReportEndDate;
                        tblReportSummery.Type            = reportSummery.Type;

                        context.TblReportSummery.Add(tblReportSummery);
                        context.SaveChanges();

                        var report_id = tblReportSummery.ReportId;

                        TblReportSummeryDetails tblReportSummeryDetails = new TblReportSummeryDetails();

                        tblReportSummeryDetails.ReportId               = report_id;
                        tblReportSummeryDetails.Crid                   = 1;
                        tblReportSummeryDetails.ActivityId             = 1;
                        tblReportSummeryDetails.OnshoreTotalHrs        = reportSummery.onShoreTotalHrs;
                        tblReportSummeryDetails.OnshoreLastWeekHrs     = reportSummery.onShoreHrsTillLastWeek;
                        tblReportSummeryDetails.OnshoreCurrentWeekHrs  = reportSummery.onShoreHrsCurrentWeek;
                        tblReportSummeryDetails.OffShoreTotalHrs       = reportSummery.offShoreTotalHrs;
                        tblReportSummeryDetails.OffshoreLastWeekHrs    = reportSummery.offShoreHrsTillLastWeek;
                        tblReportSummeryDetails.OffshoreCurrentWeekHrs = reportSummery.offShoreHrsCurrentWeek;
                        tblReportSummeryDetails.Accomplishments        = reportSummery.accomp;
                        tblReportSummeryDetails.ClientAwtInfo          = reportSummery.clientAwtInfo;
                        tblReportSummeryDetails.Notes                  = reportSummery.notes;

                        context.TblReportSummeryDetails.Add(tblReportSummeryDetails);
                        context.SaveChanges();

                        foreach (CRDetails cR in reportSummery.crDetails)
                        {
                            TblReportCr tblReportCr = new TblReportCr();

                            tblReportCr.ReportId    = report_id;
                            tblReportCr.CrName      = cR.crName;
                            tblReportCr.ActualHrs   = cR.actualHrs;
                            tblReportCr.EstimateHrs = cR.estimateHrs;
                            tblReportCr.Status      = cR.status;

                            context.TblReportCr.Add(tblReportCr);
                        }
                        context.SaveChanges();

                        foreach (ActivityDetails AD in reportSummery.activityDetails)
                        {
                            TblReportActivity tblReportActivity = new TblReportActivity();

                            tblReportActivity.ReportId   = report_id;
                            tblReportActivity.Milestones = AD.milestones;
                            tblReportActivity.Eta        = AD.eta;

                            context.TblReportActivity.Add(tblReportActivity);
                        }
                        context.SaveChanges();
                        if (reportSummery.projectType == "Week")
                        {
                            //var mail = reportSummery.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
                            //EmailHelper.ReportUploaded(mail, emailSender, "", reportSummery);
                        }
                        else
                        {
                            var mail = reportSummery.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
                            EmailHelper.ReportSubmitted(mail, emailSender, "", reportSummery);
                        }
                        return(Ok(report_id));
                    }
                    else
                    {
                        //code for update

                        TblReportSummery tblReportSummery = context.TblReportSummery.SingleOrDefault(x => x.ReportId == reportSummery.id);

                        if (tblReportSummery != null)
                        {
                            tblReportSummery.ClientName  = reportSummery.clientName;
                            tblReportSummery.ProjectName = reportSummery.projectName;
                            tblReportSummery.ProjectType = reportSummery.projectType;
                            //tblReportSummery.ReportStartDate = Convert.ToDateTime("2019-01-01");
                            //tblReportSummery.ProjectEndDate = Convert.ToDateTime("2019-01-01");
                            //tblReportSummery.CreatedBy = reportSummery.CreatedBy;
                            //tblReportSummery.CreatedDate = DateTime.Now;
                            tblReportSummery.LastUpdatedBy   = reportSummery.CreatedBy;
                            tblReportSummery.LastUpdatedDate = DateTime.Now;
                            tblReportSummery.ApprovedBy      = "UpdateAdmin";
                            tblReportSummery.ApprovedDate    = DateTime.Now;
                            tblReportSummery.Remark          = reportSummery.notes;
                            tblReportSummery.IsApproved      = true;
                            tblReportSummery.ReportStatus    = reportSummery.projectType == "Week" ? Convert.ToInt32(ReportStatus.Uploaded) : Convert.ToInt32(ReportStatus.Created);;

                            context.SaveChanges();
                        }

                        TblReportSummeryDetails tblReportSummeryDetails = context.TblReportSummeryDetails.SingleOrDefault(x => x.ReportId == reportSummery.id);

                        if (tblReportSummeryDetails != null)
                        {
                            ///tblReportSummeryDetails.ReportId = report_id;
                            tblReportSummeryDetails.Crid                   = 1;
                            tblReportSummeryDetails.ActivityId             = 1;
                            tblReportSummeryDetails.OnshoreTotalHrs        = reportSummery.onShoreTotalHrs;
                            tblReportSummeryDetails.OnshoreLastWeekHrs     = reportSummery.onShoreHrsTillLastWeek;
                            tblReportSummeryDetails.OnshoreCurrentWeekHrs  = reportSummery.onShoreHrsCurrentWeek;
                            tblReportSummeryDetails.OffShoreTotalHrs       = reportSummery.offShoreTotalHrs;
                            tblReportSummeryDetails.OffshoreLastWeekHrs    = reportSummery.offShoreHrsTillLastWeek;
                            tblReportSummeryDetails.OffshoreCurrentWeekHrs = reportSummery.offShoreHrsCurrentWeek;
                            tblReportSummeryDetails.Accomplishments        = reportSummery.accomp;
                            tblReportSummeryDetails.ClientAwtInfo          = reportSummery.clientAwtInfo;
                            tblReportSummeryDetails.Notes                  = reportSummery.notes;

                            context.SaveChanges();
                        }

                        //delete existing entry
                        // db.ProRel.RemoveRange(db.ProRel.Where(c => c.ProjectId == Project_id));
                        context.TblReportCr.RemoveRange(context.TblReportCr.Where(x => x.ReportId == reportSummery.id));
                        context.SaveChanges();

                        foreach (CRDetails cR in reportSummery.crDetails)
                        {
                            TblReportCr tblReportCr = new TblReportCr();

                            tblReportCr.ReportId    = reportSummery.id;
                            tblReportCr.CrName      = cR.crName;
                            tblReportCr.ActualHrs   = cR.actualHrs;
                            tblReportCr.EstimateHrs = cR.estimateHrs;
                            tblReportCr.Status      = cR.status;

                            context.TblReportCr.Add(tblReportCr);
                        }
                        context.SaveChanges();

                        //delete existing entry
                        context.TblReportActivity.RemoveRange(context.TblReportActivity.Where(x => x.ReportId == reportSummery.id));

                        foreach (ActivityDetails AD in reportSummery.activityDetails)
                        {
                            TblReportActivity tblReportActivity = new TblReportActivity();

                            tblReportActivity.ReportId   = reportSummery.id;
                            tblReportActivity.Milestones = AD.milestones;
                            tblReportActivity.Eta        = AD.eta;

                            context.TblReportActivity.Add(tblReportActivity);
                        }
                        context.SaveChanges();
                        if (reportSummery.projectType == "Week")
                        {
                            //var mail = reportSummery.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
                            //EmailHelper.ReportUploaded(mail, emailSender, "", reportSummery);
                        }
                        else
                        {
                            var mail = reportSummery.CreatedByEmail + ";" + _managerSettings.Value.ManagerEmail;
                            EmailHelper.ReportSubmitted(mail, emailSender, "", reportSummery);
                        }
                        return(Ok(reportSummery.id));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }