Exemplo n.º 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;
     }
 }
Exemplo n.º 2
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 static void ReportUploaded(string email, IEmailSender svc, string attachment, ReportSummery reportSummery)
 {
     Task.Run(async() =>
     {
         var sb = new StringBuilder();
         sb.Append($"<h2>Report has been Uploaded</h2>");
         sb.Append($"<h4>Client Name:  {reportSummery.clientName}</h4>");
         sb.Append($"<h4>Project Name:  {reportSummery.projectName}</h4>");
         sb.Append($"<h4>Report Type:  {reportSummery.projectType}</h4>");
         //email = email + ";" + _managerSettings.Value.ManagerEmail;
         var body = sb.ToString();
         await SendEmail("Report Uploaded!", "", email, "", "", body, new List <string>()
         {
             attachment
         }, true, svc);
     });
 }
 public static void ReportSaved(string email, IEmailSender svc, string attachment, ReportSummery reportSummery)
 {
     Task.Run(async() =>
     {
         var sb = new StringBuilder();
         sb.Append($"<h2>Report has been saved successfully</h2>");
         sb.Append($"<h4>Client Name:  {reportSummery.clientName}</h4>");
         sb.Append($"<h4>Project Name:  {reportSummery.projectName}</h4>");
         sb.Append($"<h4>Report Type:  {reportSummery.projectType}</h4>");
         var body = sb.ToString();
         await SendEmail("Report saved!", "", email, "", "", body, new List <string>()
         {
             attachment
         }, true, svc);
     });
 }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
            }
        }