コード例 #1
0
        public IHttpActionResult PostPAT(PAT PAT)
        {
            if (PAT == null)
            {
                return(BadRequest("pat object cannot be found the http request body"));
            }
            try
            {
                PAT.CreatedDate = DateTime.Now;
                var id            = jobsService.InsertPAT(PAT);
                var projectTaskId = jobsService.GetJob(PAT.JobId).ProjectTaskId;
                if (projectTaskId != null)
                {
                    projectsService.FinishTaskPercentage((int)projectTaskId);
                }
                var inspectors = authService.GetInspectorUsers().ToList();
                Notification.Email(inspectors, NotificationObjectType.PAT, PAT);
                Notification.System(inspectors, NotificationObjectType.PAT, User.UserId, Url.Link("JobDetails", new { id = PAT.JobId }), PAT);
                //Notification.OnEmailNotification += (a1, a2) =>
                //{
                //    return new EmailStatus();
                //};
                // Log.Inforamtion(Type.Sql, "log title", "log body")
                // Log.Error(Type.Sql, "log title", "log body")
                // Log.Warning(Type.Csv, "log title", "log text")

                var pats = jobsService.GetJobPATs(PAT.JobId);
                var html = Helpers.RenderPartial("~/Views/Shared/Partial/Jobs/PATs.cshtml", pats);

                return(Ok(html));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }