Exemple #1
0
        public bool Save(DailyScrum dailyScrum)
        {
            try
            {
                DailyScrum ret = null;
                if (!_context.DailyScrums.EntityChange(dailyScrum))
                {
                    ret = _context.DailyScrums.Create(dailyScrum);
                }
                //else
                //   ret = _context.DailyScrums.Update(dailyScrum);


                if (ret == null)
                {
                    return(false);
                }

                var templatePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
                templatePath = templatePath.Remove(0, 6);

                var dailyScrumEmail = new DailyScrumEmail();
                foreach (var item in dailyScrum.DailyProjectScrums)
                {
                    var project = _projectManager.Get(item.ProjectId);
                    var client  = _clientManager.GetByProjectId(item.ProjectId);
                    dailyScrumEmail.DailyProjectScrums.Add(
                        new DailyProjectScrumEmail
                    {
                        ClientName       = client.Name,
                        ProjectName      = project.Name,
                        SpentTime        = item.SpentTime,
                        WhatDoneLastTime = item.WhatDoneLastTime,
                        WhatProblems     = item.WhatProblems,
                        WhatToDoNext     = item.WhatToDoNext
                    }
                        );
                }

                var email = Email
                            .From(dailyScrum.User.Email, dailyScrum.User.UserName)
                            .To(Settings.Default.NotificationEmail)
                            .BCC(dailyScrum.User.Email, dailyScrum.User.UserName)
                            .Subject(Resource.DailyScrumEmailSubgect)
                            .UsingTemplateFromFile(Path.Combine(templatePath, "EmailTemplates\\DailyScrum.cshtml"), dailyScrumEmail);

                email.Send();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Exception: {0}", ex);
                return(false);
            }

            return(true);
        }
        public bool Save(DailyScrum dailyScrum)
        {
            try
            {
                DailyScrum ret = null;
                if (!_context.DailyScrums.EntityChange(dailyScrum))
                    ret = _context.DailyScrums.Create(dailyScrum);
                //else
                //   ret = _context.DailyScrums.Update(dailyScrum);

                if (ret == null)
                    return false;

                var templatePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
                templatePath = templatePath.Remove(0, 6);

                var dailyScrumEmail = new DailyScrumEmail();
                foreach (var item in dailyScrum.DailyProjectScrums)
                {
                    var project = _projectManager.Get(item.ProjectId);
                    var client = _clientManager.GetByProjectId(item.ProjectId);
                    dailyScrumEmail.DailyProjectScrums.Add(
                        new DailyProjectScrumEmail
                        {
                            ClientName = client.Name,
                            ProjectName = project.Name,
                            SpentTime = item.SpentTime,
                            WhatDoneLastTime = item.WhatDoneLastTime,
                            WhatProblems = item.WhatProblems,
                            WhatToDoNext = item.WhatToDoNext
                        }
                    );
                }

                var email = Email
                    .From(dailyScrum.User.Email, dailyScrum.User.UserName)
                    .To(Settings.Default.NotificationEmail)
                    .BCC(dailyScrum.User.Email, dailyScrum.User.UserName)
                    .Subject(Resource.DailyScrumEmailSubgect)
                    .UsingTemplateFromFile(Path.Combine(templatePath, "EmailTemplates\\DailyScrum.cshtml"), dailyScrumEmail);

                email.Send();

            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Exception: {0}", ex);
                return false;
            }

            return true;
        }