private object CreateReviewRecord(MarkRequest arg) { var myLogin = GetCurrentLogin(); // UserNameHelper.GetUserName() var connector = new AdConnector(); var user = connector.GetUserByLoginOrDefault(myLogin); return new { Name = connector.GetUserByLoginOrDefault(arg.To), Marks = new Marks() }; }
public void CreateMarkRequest(MarkRequest markRequest) { string sqlQuery = @"INSERT INTO [dbo].[RatingRequest] ([From] ,[To] ,[ExpirationDate]) VALUES (@From, @To, @ExpirationDate)"; var param = new { From = markRequest.From, To = markRequest.To, ExpirationDate = markRequest.ExpirationDate }; using (DbConnection connection = connectionFactory.Create()) { connection.Execute(sqlQuery, param); } }
public void UpdateMarkRequest(MarkRequest markRequest) { string sqlQuery = @"UPDATE [dbo].[RatingRequest] SET [ExpirationDate] = @ExpirationDate WHERE Id = @Id"; var param = new { Id = markRequest.Id, ExpirationDate = markRequest.ExpirationDate }; using (DbConnection connection = connectionFactory.Create()) { connection.Execute(sqlQuery, param); } }
public ActionResult SendReviewRequest(MarkRequest request) { requestRepository.CreateMarkRequest(request); if (request.ExpirationDate == DateTime.MinValue) { request.ExpirationDate = GetDefaultExpirationDate(); } SecureString pwd = new SecureString(); WebConfigurationManager.AppSettings["SmtpPassword"].ToCharArray().ToList().ForEach(x => pwd.AppendChar(x)); var sender = new MailSender(new SmtpConfig { Domain = WebConfigurationManager.AppSettings["SmtpDomain"], SmtpServer = WebConfigurationManager.AppSettings["SmtpServer"], Password = pwd, UserName = WebConfigurationManager.AppSettings["SmtpLogin"] }); var connector = new AdConnector(); var currentUser = connector.GetUserById(System.Environment.UserName); var fromUser = connector.GetUserById(request.From); var toUser = connector.GetUserById(request.To); string subject = string.Format("{2} просит оценить сотрудника {0} до {1}", toUser.FullName, request.ExpirationDate.ToShortDateString(), currentUser.FullName); string body = String.Format("Для оценки пройдите по ссылке: {0}", string.Format("{0}://{1}{2}/ReviewRequestForMe", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"))); sender.Send(subject, body, currentUser, toUser); return Json("", JsonRequestBehavior.AllowGet); }
private object CreateReviewRequestObject(MarkRequest request) { return new { Reviewer = request.From, Reviewee = request.To, request.ExpirationDate }; }