public void GetUsersByFilterFullName_CorrectManager_NotEmptyCollection()
 {
     var connector = new AdConnector();
     var users = connector.GetUsersByFilterFullName("хлебников");
     Assert.Equal(1, users.Count);
     Assert.Equal("Хлебников Сергей", users.First().FullName);
 }
        //        private string GetCurrentLogin()
        //        {
        //            return HttpContext.Request.LogonUserIdentity.Name.Split(new string[] { @"\\" }, StringSplitOptions.RemoveEmptyEntries)[0];
        //        }
        public ActionResult Save(string Name, Marks Marks)
        {
            if (Marks == null || !Marks.Validate())
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Для оценки, отличной от S коментарий обязателен.");
            }

            try
            {
                var myLogin = GetCurrentLogin(); // UserNameHelper.GetUserName()
                var connector = new AdConnector();
                var user = connector.GetUserByLoginOrDefault(myLogin);
                var record = new MarkRecord
                {
                    DateCreated = DateTime.UtcNow,
                    From = user.Login,
                    Marks = Marks,
                    To = Name
                };
                repository.CreateMark(record);
                return Json("");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message);
            }
        }
 //        {
 //        From: "Me",
 //        Time: "22:00",
 //        Productivity: { MarkLevel: "E", Comment: "Good! nice" },
 //        Quality: { MarkLevel: "E", Comment: "Good! nice" },
 //        Discipline: { MarkLevel: "E", Comment: "Good! nice" },
 //        Cooperation: { MarkLevel: "E", Comment: "Good! nice" }
 //    }
 private object GetRatings()
 {
     var myLogin = GetCurrentLogin(); // UserNameHelper.GetUserName()
     var connector = new AdConnector();
     var user = connector.GetUserByLoginOrDefault(myLogin);
     var marks = repository.GetMarksCreatedForMe(user.Login);
     return marks.Select(CreateReview).ToList();
 }
 public void GetUserByLoginOrDefault_ValidParams_ValidUser()
 {
     var connector = new AdConnector();
     var user = connector.GetUserByLoginOrDefault("Erygin.Ale");
     Assert.NotNull(user);
     Assert.NotNull(user.Login);
     Assert.NotNull(user.Manager);
 }
        public ActionResult GetUsers()
        {
            var connector = new AdConnector();
            var minions = connector.GetUsersByManager(UserLogonName)
                .Select(x => new { Name = x.FullName, Id = x.Login });

            return Json(minions, JsonRequestBehavior.AllowGet);
        }
        public void GetUserById_GoodId_NotNull()
        {
            var connector = new AdConnector();
            var user = connector.GetUserByLoginOrDefault("Erygin.Ale");
            var id = user.Login;

            var user2 = connector.GetUserById(id);
            Assert.NotNull(user2);
        }
 public ActionResult ReviewRequests()
 {
     var connector = new AdConnector();
     var user = connector.GetUserByLoginOrDefault(UserLogonName);
     var requests = requestRepository.GetMarkRequestsCreatedByMe(user.Login)
         .Select(CreateReviewRequestObject)
         .ToList();
     return Json(requests, JsonRequestBehavior.AllowGet);
 }
        public ActionResult GetUsers()
        {
            var myLogin = GetCurrentLogin(); // UserNameHelper.GetUserName()
            var connector = new AdConnector();
            var minions = connector.GetUsersByManager(myLogin)
                .Select(x => new { Name = x.FullName, Id = x.Login });

            return Json(minions, JsonRequestBehavior.AllowGet);
        }
 public void GetUsersByManager_CorrectManager_NotEmptyCollection()
 {
     var connector = new AdConnector();
     var users = connector.GetUsersByManager("SeleverstovIA");
     Assert.NotEmpty(users);
 }
 public void GetAllUsers_NotEmptyList()
 {
     var connector = new AdConnector();
     var users = connector.GetAllUsers();
     Assert.NotEmpty(users);
 }
 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 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);
        }