Пример #1
0
        public IHttpActionResult ApproveProject(Guid rid)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);

            if (dbReview == null)
            {
                return(new SkyApiNotFound(Request));
            }

            dbReview.ApprovedById   = UserRecord.Id;
            dbReview.ApprovedByName = UserRecord.FullName;
            dbReview.ApprovedByIp   = ""; // TODO djw: record requesting users IP address
            dbReview.ApprovedDate   = DateTime.UtcNow;

            UOW.Commit();

            IDictionary <string, string> formData = new Dictionary <string, string>();

            formData.Add("User", UserRecord.FullName);
            formData.Add("Project", dbReview.Project.Name);
            formData.Add("Review", dbReview.Title);
            MailService.SendNotification(formData, "Skyberry Notification: Project Approval");

            ReviewApprovedVM reviewApprovedVM = new ReviewApprovedVM
            {
                ApprovedById   = dbReview.ApprovedById,
                ApprovedByName = dbReview.ApprovedByName,
                ApprovedByIp   = dbReview.ApprovedByIp,
                ApprovedDate   = dbReview.ApprovedDate,
            };

            return(new SkyApiPayload <ReviewApprovedVM>(Request, reviewApprovedVM));
        }
        public IHttpActionResult ApproveProject(Guid rid)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);
            if (dbReview == null)
            {
                return new SkyApiNotFound(Request);
            }

            dbReview.ApprovedById = UserRecord.Id;
            dbReview.ApprovedByName = UserRecord.FullName;
            dbReview.ApprovedByIp = ""; // TODO djw: record requesting users IP address
            dbReview.ApprovedDate = DateTime.UtcNow;

            UOW.Commit();

            IDictionary<string, string> formData = new Dictionary<string, string>();
            formData.Add("User", UserRecord.FullName);
            formData.Add("Project", dbReview.Project.Name);
            formData.Add("Review", dbReview.Title);
            MailService.SendNotification(formData, "Skyberry Notification: Project Approval");

            ReviewApprovedVM reviewApprovedVM = new ReviewApprovedVM
            {
                ApprovedById = dbReview.ApprovedById,
                ApprovedByName = dbReview.ApprovedByName,
                ApprovedByIp = dbReview.ApprovedByIp,
                ApprovedDate = dbReview.ApprovedDate,
            };
            return new SkyApiPayload<ReviewApprovedVM>(Request, reviewApprovedVM);
        }