コード例 #1
0
        private void SendEmail(string email)
        {
            List <User> users = ManagerLogic.GetAllUsers();

            try
            {
                string subject = "Verify Password";
                body = CreatePassword(6);
                string      FromMail   = "*****@*****.**";
                string      emailTo    = "*****@*****.**";//email;
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress(FromMail);
                mail.To.Add(emailTo);
                mail.Subject = subject;
                mail.Body    = body;
                SmtpServer.UseDefaultCredentials = true;
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new NetworkCredential("*****@*****.**", "0556774766");
                SmtpServer.EnableSsl   = true;
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                var x = ex.Message;
            }
        }
コード例 #2
0
        public HttpResponseMessage EditPassword([FromBody] User value)
        {
            if (ModelState.IsValid)
            {
                return((ManagerLogic.UpdatePassword(value)) ?
                       new HttpResponseMessage(HttpStatusCode.OK) :
                       new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
                });
            }
            ;
            List <string> ErrorList = new List <string>();

            //if the code reached this part - the user is not valid
            foreach (var item in ModelState.Values)
            {
                foreach (var err in item.Errors)
                {
                    ErrorList.Add(err.ErrorMessage);
                }
            }
            return(new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new ObjectContent <List <string> >(ErrorList, new JsonMediaTypeFormatter())
            });
        }
コード例 #3
0
 public HttpResponseMessage GetAllWorkers()
 {
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <List <User> >(ManagerLogic.GetAllUsers(), new JsonMediaTypeFormatter())
     });
 }
コード例 #4
0
 public HttpResponseMessage getAllProjects()
 {
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <List <Project> >(ManagerLogic.getAllProjects(), new JsonMediaTypeFormatter())
     });
 }
コード例 #5
0
 public HttpResponseMessage GetPresence()
 {
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <List <Object> >(ManagerLogic.GetPresence(), new JsonMediaTypeFormatter())
     });
 }
コード例 #6
0
ファイル: Login.ashx.cs プロジェクト: huangliliu0917/BMeng
        public new void ProcessRequest(HttpContext context)
        {
            ClearCookies();
            string          loginName     = GetFormValue("loginName", "");
            string          loginPassword = EncryptHelper.MD5(GetFormValue("password", ""));
            int             loginType     = GetFormValue("loginType", 0);
            string          json          = string.Empty;
            AdminLoginModel data          = UserLogic.Login(loginName, loginPassword, loginType == 1);

            if (data != null)
            {
                //判断账户是否已启用
                if (data.UserStatus == 1)
                {
                    WriteCookies(data);
                    if (data.UserIndentity == 0)
                    {
                        ManagerLogic.UpdateLastLoginTime(data.ID);
                    }
                    json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK));
                }
                else
                {
                    json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.账户已禁用));
                }
            }
            else
            {
                json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.账户密码不正确));
            }

            context.Response.ContentType = "application/json";
            context.Response.Write(json);
        }
コード例 #7
0
 public HttpResponseMessage GetPresence()
 {
     //curl -X GET -v http://localhost:59628/api/GetPresence
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <List <Object> >(ManagerLogic.GetPresence(), new JsonMediaTypeFormatter())
     });
 }
コード例 #8
0
        public void Given_ManagerEntity_When_CallingManagerLogicConstructor_Then_CheckIfManagerEntityIsNotNull()
        {
            //Arrange && Act
            var managerLogic = new ManagerLogic(managerEntity);

            //Assert
            managerLogic.Should().NotBeNull();
        }
コード例 #9
0
ファイル: ManagerController.cs プロジェクト: rachelnovak/node
 public HttpResponseMessage GetAllWorkers()
 {
     //curl -X GET -v http://localhost:59628/api/getAllWorkers
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <List <User> >(ManagerLogic.GetAllUsers(), new JsonMediaTypeFormatter())
     });
 }
コード例 #10
0
 public HttpResponseMessage addWorkersToProject([FromBody] int[] ids, [FromUri] string name)
 {
     //curl -v -X POST -H "Content-type: application/json" -d "{\"Name\":\"tryProject\", \"Customer\":\"nnn\",\"TeamLeaderId\":\"11\" , \"DevelopHours\":\"300\",\"QAHours\":\"250\", \"UiUxHours\":\"100\",\"StartDate\":\"2018-02-02\",\"EndDate\":\"2018-07-07\"}"  http://localhost:59628/api/addProject
     return((ManagerLogic.addWorkersToProject(ids, name)) ?
            new HttpResponseMessage(HttpStatusCode.OK) :
            new HttpResponseMessage(HttpStatusCode.BadRequest)
     {
         Content = new ObjectContent <String>("Can not update in Data Base", new JsonMediaTypeFormatter())
     });
 }
コード例 #11
0
 public HttpResponseMessage DeleteWorker(int id)
 //curl -X DELETE -v http://localhost:59628/api/deleteWorker/id=8
 {
     return((ManagerLogic.RemoveWorker(id)) ?
            new HttpResponseMessage(HttpStatusCode.OK) :
            new HttpResponseMessage(HttpStatusCode.BadRequest)
     {
         Content = new ObjectContent <String>("Can not remove from DB", new JsonMediaTypeFormatter())
     });
 }
コード例 #12
0
        public void Given_ManagerEntityAndManagerLogic_When_CallingGetFullNameMehtod_Then_ReturnTheFullNameOfTheManager()
        {
            //Arrange
            var managerLogic = new ManagerLogic(managerEntity);

            //Act
            var fullNameOFTheManager = managerLogic.GetFullName();

            //Assert
            fullNameOFTheManager.Should().Be("Dumitru Mafia");
        }
コード例 #13
0
        public void Given_ManagerEntityAndManagerLogic_When_CallingIsActive_Then_ReturnTrueIfEndDateIsBiggerThanTheStartDateAndIfManagerEntityIsNotNull()
        {
            //Arrange
            var managerLogic = new ManagerLogic(managerEntity);

            //Act
            var isActive = managerLogic.isActive();

            //Assert
            isActive.Should().BeTrue();
        }
コード例 #14
0
 public HttpResponseMessage addWorkersToProject([FromBody] int[] ids, [FromUri] string name)
 {
     return((ManagerLogic.addWorkersToProject(ids, name)) ?
            new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
     } :
            new HttpResponseMessage(HttpStatusCode.BadRequest)
     {
         Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
     });
 }
コード例 #15
0
 public HttpResponseMessage DeleteWorker(int id)
 {
     return((ManagerLogic.RemoveUser(id)) ?
            new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
     } :
            new HttpResponseMessage(HttpStatusCode.BadRequest)
     {
         Content = new ObjectContent <String>("Can not remove from DB", new JsonMediaTypeFormatter())
     });
 }
コード例 #16
0
 public HttpResponseMessage AddProject([FromBody] Project value)
 {
     //curl -v -X POST -H "Content-type: application/json" -d "{\"Name\":\"tr1\", \"Customer\":\"nnn\",\"TeamLeaderId\":\"21\" , \"DevelopHours\":\"300\",\"QAHours\":\"250\", \"UiUxHours\":\"100\",\"StartDate\":\"2018-02-02\",\"EndDate\":\"2018-07-07\"}"  http://localhost:59628/api/addProject
     if (ModelState.IsValid)
     {
         return((ManagerLogic.AddProject(value)) ?
                new HttpResponseMessage(HttpStatusCode.Created) :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not add to DB", new JsonMediaTypeFormatter())
         });
     }
     return(Global.ErrorList(ModelState));
 }
コード例 #17
0
 public HttpResponseMessage AddWorker([FromBody] Worker value)
 {
     //curl -v -X POST -H "Content-type: application/json" -d "{\"Name\":\"Gila\",\"UserName\":\"gggg\",\"Password\":\"gggggg\",\"JobId\":\"4\",\"EMail\":\"safdsa@fdsaf\",\"ManagerId\":\"11\"}"  http://localhost:59628/api/addWorker
     //
     if (ModelState.IsValid)
     {
         return((ManagerLogic.AddWorker(value)) ?
                new HttpResponseMessage(HttpStatusCode.Created) :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not add to DB", new JsonMediaTypeFormatter())
         });
     }
     return(Global.ErrorList(ModelState));
 }
コード例 #18
0
 public HttpResponseMessage AddWorker([FromBody] User value)
 {
     if (ModelState.IsValid || ModelState["ManagerId"] == null)
     {
         return((ManagerLogic.AddUser(value)) ?
                new HttpResponseMessage(HttpStatusCode.Created)
         {
             Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
         } :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not add to DB", new JsonMediaTypeFormatter())
         });
     }
     return(Global.ErrorList(ModelState));
 }
コード例 #19
0
        public HttpResponseMessage VerifyEmail(string userName)
        {
            List <User> users = ManagerLogic.GetAllUsers();

            user = users.FindLast(u => u.UserName == userName);
            if (user != null)
            {
                string email = "*****@*****.**"; //user.EMail;
                SendEmail(email);
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "error"));
            }
        }
コード例 #20
0
        public HttpResponseMessage UpdateWorker([FromBody] Worker value)
        {
            //curl -v -X PUT -H "Content-type: application/json" -d "{\"Id\":\"7\",\"Name\":\"Malki\", \"UserName\":\"ggggg\",\"Password\":\"mmmggg\" , \"JobId\":\"3\",\"EMail\":\"sjafjkl@dfaf\", \"ManagerId\":\"5\"}"  http://localhost:59628/api/UpdateWorker
            if (ModelState.IsValid || ModelState["Password"] == null)
            {
                return((ManagerLogic.UpdateWorker(value)) ?
                       new HttpResponseMessage(HttpStatusCode.OK) :
                       new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
                });
            }
            ;

            return(Global.ErrorList(ModelState));
        }
コード例 #21
0
 public HttpResponseMessage UpdateWorker([FromBody] User value)
 {
     if (ModelState.IsValid || ModelState["Password"] == null)
     {
         return((ManagerLogic.UpdateUser(value)) ?
                new HttpResponseMessage(HttpStatusCode.OK)
         {
             Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
         } :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
         });
     }
     ;
     return(Global.ErrorList(ModelState));
 }
コード例 #22
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            SubscribersLogic sl = new SubscribersLogic();
            InstructorsLogic il = new InstructorsLogic();
            ManagerLogic     ml = new ManagerLogic();

            if (sl.checkUser(pass.Text, ID.Text))
            {
                Label1.Text         = "you have successfully loggin";
                Session["Id"]       = ID.Text;
                Session["nameUser"] = sl.getUserName(Session["Id"].ToString());
                Session["Type"]     = "Subscriber";
                Response.Redirect("HomeSubscribers.aspx");
            }
            else
            {
                if (il.isInstructors(pass.Text, ID.Text))
                {
                    Label1.Text         = "you have successfully loggin";
                    Session["Id"]       = ID.Text;
                    Session["nameUser"] = il.getInstructorName(Session["Id"].ToString());
                    Session["Type"]     = "Instructor";
                    Response.Redirect("HomeInstructor.aspx");
                }
                else
                {
                    if (ml.isManager(pass.Text, ID.Text))
                    {
                        Label1.Text         = "you have successfully loggin";
                        Session["Id"]       = ID.Text;
                        Session["nameUser"] = ml.getManagerName(Session["Id"].ToString());
                        Session["Type"]     = "Manager";
                        Response.Redirect("HomeManager.aspx");
                    }
                    else
                    {
                        Label1.Text = "id or passwod are wrong";
                    }
                }
            }
        }
コード例 #23
0
        static Dependencies()
        {
            var roleDaoSet = ConfigurationManager.AppSettings["roleDaoSet"];

            switch (roleDaoSet)
            {
            case "1":
                roleDao = new RoleDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(roleDaoSet)}!");
            }

            var userDaoSet = ConfigurationManager.AppSettings["userDaoSet"];

            switch (userDaoSet)
            {
            case "1":
                userDao = new UserDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(userDaoSet)}!");
            }

            var customerDaoSet = ConfigurationManager.AppSettings["customerDaoSet"];

            switch (customerDaoSet)
            {
            case "1":
                productDao = new ProductDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(customerDaoSet)}!");
            }

            var productDaoSet = ConfigurationManager.AppSettings["productDaoSet"];

            switch (productDaoSet)
            {
            case "1":
                customerDao = new CustomerDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(productDaoSet)}!");
            }

            var orderDaoSet = ConfigurationManager.AppSettings["orderDaoSet"];

            switch (orderDaoSet)
            {
            case "1":
                orderDao = new OrderDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(orderDaoSet)}!");
            }

            var orderProductDaoSet = ConfigurationManager.AppSettings["orderProductDaoSet"];

            switch (orderProductDaoSet)
            {
            case "1":
                orderProductDao = new OrderProductDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(orderProductDaoSet)}!");
            }

            var managerDaoSet = ConfigurationManager.AppSettings["managerDaoSet"];

            switch (managerDaoSet)
            {
            case "1":
                managerDao = new ManagerDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(managerDaoSet)}!");
            }

            var loggerDaoSet = ConfigurationManager.AppSettings["loggerDaoSet"];

            switch (loggerDaoSet)
            {
            case "2":
                loggerDao = new LoggerDaoFile();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(loggerDaoSet)}!");
            }

            var feedbackDaoSet = ConfigurationManager.AppSettings["feedbackDaoSet"];

            switch (feedbackDaoSet)
            {
            case "1":
                feedbackDao = new FeedbackDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(feedbackDaoSet)}!");
            }

            RoleLogic         = new RoleLogic(roleDao, loggerDao);
            UserLogic         = new UserLogic(userDao, loggerDao);
            CustomerLogic     = new CustomerLogic(customerDao, loggerDao);
            ProductLogic      = new ProductLogic(productDao, loggerDao);
            OrderLogic        = new OrderLogic(orderDao, loggerDao);
            OrderProductLogic = new OrderProductLogic(orderProductDao, loggerDao);
            ManagerLogic      = new ManagerLogic(managerDao, loggerDao);
            LoggerLogic       = new LoggerLogic(loggerDao);
            FeedbackLogic     = new FeedbackLogic(feedbackDao, loggerDao);
        }