コード例 #1
0
        public ActionResult Approve(int id)
        {
            int      ID   = id;
            tblSkill idea = entity.tblSkills.FirstOrDefault(g => g.skId == id);

            idea.skStatus            = "Approved";
            entity.Entry(idea).State = System.Data.Entity.EntityState.Modified;
            entity.SaveChanges();
            return(RedirectToAction("ConfirmEmail", new { id = ID }));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "idColaborador,Nome,Email,CPF,Senha,Oficio,DataNascimento,Sexo,Telefone,Disponibilidade")] Colaborador colaborador)
        {
            if (ModelState.IsValid)
            {
                db.Colaborador.Add(colaborador);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(colaborador));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "UserId,UserName,Password,IsActive")] UserProfile userProfile)
        {
            if (ModelState.IsValid)
            {
                db.UserProfiles.Add(userProfile);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userProfile));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "UserID,Username,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "skId,skName,skExperience,skPrevProjects,skCurrentProject,skDomain,skUsername")] tblSkill tblSkill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblSkill).State = EntityState.Modified;
         db.SaveChanges();
         string un = loggedinUser;
         return(RedirectToAction("Dashboard_Employee", new { uname = loggedinUser }));
     }
     return(View(tblSkill));
 }
コード例 #6
0
        public ActionResult Create([Bind(Include = "usuarioId,Nombre,CorreoElectronico,nombreus,pass")] Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                db.Usuario.Add(usuario);
                db.SaveChanges();
                return(RedirectToAction("/Index", "Login"));
            }

            return(View(usuario));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "ID,Usr,Password,Email,Phone")] User user)
        {
            if (ModelState.IsValid)
            {
                Guid guid = Guid.NewGuid();
                user.ID = guid.ToString("D");

                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
コード例 #8
0
        public void SendEmail(string email)
        {
            //string message = "This email address does not match our records.";
            tblLogin user;

            user = entities.tblLogins.Where(x => x.eEmail == email).FirstOrDefault();

            if (user != null)
            {
                string username = user.eEmail;
                string password = user.ePassword;

                // To send OTP to email
                string strNewPassword = GeneratePassword().ToString();
                user.OTP = strNewPassword;
                entities.SaveChanges();
                if (!string.IsNullOrEmpty(password))
                {
                    MimeMessage    mm   = new MimeMessage();
                    MailboxAddress from = new MailboxAddress("ADMIN", "*****@*****.**");
                    mm.From.Add(from);

                    MailboxAddress to = new MailboxAddress(username, email);
                    mm.To.Add(to);

                    mm.Subject = "OTP For ResetPassword";
                    var body = "Hi, <br/>You recently requested to reset your password for your account.<br/><div style='background-color: white; display: block; font-family: sans-serif; text-align: center'> " +
                               "<div style='background-color:#F7F6A2; width: 80%; color: white; text-align: center; font-size: 2rem; padding: 2rem;'> Your OTP for Resetting Password:<h2 style='color:black'>{0}</h2></div><div></div>" +
                               "<br/>If you did not request a password reset, please ignore this email or reply to let us know.<br/><br/> Thank you" +
                               "</div>";
                    BodyBuilder bodyBuilder = new BodyBuilder();
                    bodyBuilder.HtmlBody = string.Format(body, user.OTP);
                    bodyBuilder.TextBody = string.Format(body, user.OTP);
                    mm.Body = bodyBuilder.ToMessageBody();


                    using (var client = new SmtpClient())
                    {
                        client.Connect("smtp.gmail.com", 465, true);
                        client.Authenticate("*****@*****.**", "dxcproject");
                        client.Send(mm);
                        client.Disconnect(true);
                        client.Dispose();
                        ViewBag.Message = string.Format("OTP Generated Successfully.");
                    }
                }
            }
        }
コード例 #9
0
        public static string deletarPessoa(pessoa p)
        {
            using (LoginEntities entities = new LoginEntities())
            {
                try
                {
                    pessoa deletePessoa = new pessoa();
                    deletePessoa = entities.pessoas.FirstOrDefault(del => del.cpf == p.cpf);

                    if (deletePessoa == null || deletePessoa.cpf.Equals(null) || deletePessoa.cpf.Equals(""))
                    {
                        return("Operação não realizada.\nNão foi encontrado ninguém com este CPF na base de dados!");
                    }
                    else
                    {
                        entities.pessoas.Remove(deletePessoa);
                        entities.SaveChanges();
                        return("Operação realizada com sucesso!\nSua conta foi apagada da base de dados.");
                    }
                }
                catch (Exception e)
                {
                    return("Erro: " + e.Message);
                }
            }
        }
コード例 #10
0
        public ActionResult Cadastrar(Colaborador novoUsuario)
        {
            var senhaCriptografada = FormsAuthentication.HashPasswordForStoringInConfigFile(novoUsuario.Senha, "MD5");

            novoUsuario.Disponibilidade = true;
            novoUsuario.Senha           = senhaCriptografada;
            contextEntities.Colaborador.Add(novoUsuario);
            contextEntities.SaveChanges();
            ViewBag.StatusCadastro = "Colaborador cadastrado com sucesso!";
            return(View("Cadastro"));
        }
コード例 #11
0
        public ActionResult Register(tblLogin data)
        {
            if (ModelState.IsValid)
            {
                tblLogin obj = entity.tblLogins.Where(x => x.eEmail == data.eEmail).FirstOrDefault();
                if (obj == null)
                {
                    entity.tblLogins.Add(data);
                    entity.SaveChanges();

                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("", "Email ID already registered.");
                    return(View("Register"));
                }
            }
            return(View(data));
        }
コード例 #12
0
        public ActionResult Transfer([Bind(Include = "AccountNumber,TransferFrom,TransferTo,TransferAmount,TransferDate,CurrentBalance,Funds,CustomerName")] TransactionDetail transactionDetail)
        {
            if (Session["UserName"] != null && Session["UserRole"].ToString().Contains("Customer"))
            {
                if (ModelState.IsValid)
                {
                    transactionDetail.TransferDate  = DateTime.Now;
                    transactionDetail.AccountNumber = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.TransferFrom  = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.CustomerName  = Convert.ToString(Session["CustomerName"]);
                    db2.TransactionDetails.Add(transactionDetail);
                    db2.SaveChanges();

                    //Receivers Balance Increases
                    BanksCustomer banksCustomer = new BanksCustomer();
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferTo).FirstOrDefault();
                    LoginDetails updateBalanceReveiver = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferTo).FirstOrDefault();
                    updateBalanceReveiver.CurrentBalance += transactionDetail.TransferAmount;
                    db.Entry(updateBalanceReveiver).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    //Senders Balance Decreases
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferFrom).FirstOrDefault();
                    LoginDetails updateBalanceSender = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferFrom).FirstOrDefault();
                    updateBalanceSender.CurrentBalance -= transactionDetail.TransferAmount;
                    db.Entry(updateBalanceSender).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ViewBag.ReceiversAccountNumber = new SelectList(db2.BanksCustomers.Where(u => u.UserRole.ToString().Contains("Customer")), "AccountNumber", "AccountNumber", transactionDetail.AccountNumber);
                return(View(transactionDetail));
            }

            Response.Write("<script>alert('Session logged out. Sign in again');</script>");
            FormsAuthentication.SignOut();
            Session.Clear();
            return(RedirectToAction("SignIn", "Auth"));
        }
コード例 #13
0
 public ActionResult Register(User userModel)
 {
     try
     {
         using (LoginEntities db = new LoginEntities())
         {
             db.Users.Add(userModel);
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(RedirectToAction("Index", "Login"));
 }
コード例 #14
0
        public ActionResult AddorEdit(Login login)
        {
            using (LoginEntities loginmodel = new LoginEntities())
            {
                if (loginmodel.Logins.Any(x => x.UserName == login.UserName))
                {
                    ViewBag.Dublicate = "User name found ";
                    return(View("AddorEdit", login));
                }

                loginmodel.Logins.Add(login);
                loginmodel.SaveChanges();
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Registration succesfull";
            return(View("AddorEdit", new Login()));
        }
コード例 #15
0
        public string Register(RegistrationDetails RegUser)
        {
            string Response = "Registered";

            try
            {
                using (LoginEntities ent = new LoginEntities())
                {
                    var query = (from u in ent.UserDetails
                                 where u.UserID == RegUser.UserID
                                 select u.UserID).Count();
                    if (query > 0)
                    {
                        Response = "User name already exists";
                    }
                    else
                    {
                        UserDetail user = new UserDetail()
                        {
                            FirstName   = RegUser.FirstName,
                            LastName    = RegUser.LastName,
                            UserID      = RegUser.UserID,
                            Password    = RegUser.Password,
                            PhoneNumber = RegUser.PhoneNumber,
                            EmailID     = RegUser.EmailID
                        };

                        ent.UserDetails.Add(user);
                        if (ent.SaveChanges() > 0)
                        {
                            Response = "Registered";
                        }
                        else
                        {
                            Response = "Failed to Register";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Response);
        }
コード例 #16
0
 public ActionResult Signup(User u)
 {
     if (ModelState.IsValid == true)
     {
         db.Users.Add(u);
         int a = db.SaveChanges();
         if (a > 0)
         {
             TempData["Signup"] = "<p class=\"alert alert-success\">User registered successfully</p>";
             ModelState.Clear();
             return(RedirectToAction("Index"));
         }
         else
         {
             TempData["Signup"] = "<p class=\"alert alert-danger\">User registration failed</p>";
         }
     }
     return(View());
 }
コード例 #17
0
        public ActionResult AddFund(Fund fund)
        {
            if (ModelState.IsValid)
            {
                //Customers Fund Increases into BanksCustomer Table
                BanksCustomer banksCustomer = db.BanksCustomers.Where(u => u.AccountNumber == fund.AccountNumber).FirstOrDefault();
                LoginDetails  updateFund    = db2.LoginDetails.Where(u => u.AccountNumber1 == fund.AccountNumber).FirstOrDefault();
                updateFund.Fund = banksCustomer.Fund + fund.Fund1;
                db2.Entry(updateFund).Property("Fund").IsModified = true;
                db2.SaveChanges();

                //Save Funds History into Fund Table
                db.Funds.Add(fund);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
コード例 #18
0
        public ActionResult Registre(Student s, HttpPostedFileBase img)
        {
            try
            {
                if (ModelState.IsValid == true)
                {
                    string path = Uploadimage(img);
                    if (path.Equals("-1"))
                    {
                        logger.Error("image path not find");
                    }
                    else
                    {
                        s.User_Image = path;
                        db.Students.Add(s);
                        int a = db.SaveChanges();
                        if (a > 0)
                        {
                            ViewBag.InsertMeassage = "<script>alert('register succefully !!')</script>";
                            ModelState.Clear();
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ViewBag.InsertMeassage = "<script>alert('not register succefully !!')</script>";
                        }
                    }
                }
                logger.Info("register success" + Environment.NewLine + DateTime.Now);
            }


            catch (Exception ex)
            {
                logger.ErrorException("Error occured in User controller Register Action", ex);
            }
            return(View());
        }
コード例 #19
0
        public ActionResult TransferFunds(LoginTbl obj, string btn)
        {
            if (btn == "Transfer")
            {
                var data = project.LoginTbls.Where(x => x.AccountNo == obj.AccountNo).FirstOrDefault();
                if (obj.Amount != null)
                {
                    data.Amount -= obj.Amount;
                    int mess = project.SaveChanges();
                    if (mess == 1)
                    {
                        ViewBag.data = "Transfer is Done!";
                    }
                    else
                    {
                        ViewBag.data = "Transfer is not Successfull.";
                    }
                }
                else
                {
                    ViewBag.data = "Insufficient Balance.";
                }
            }


            if (btn == "View Balance")
            {
                var data = project.LoginTbls.Where(x => x.AccountNo == obj.AccountNo).FirstOrDefault();
                ViewBag.show = "The Available balance in your account is :  " + data.Amount;
            }
            //else
            //{
            //    ViewBag.show = "Wrong Details.";
            //}

            return(View());
        }
コード例 #20
0
        public static string alterarPessoa(pessoa p)
        {
            using (LoginEntities entities = new LoginEntities())
            {
                try
                {
                    pessoa updatePessoa = new pessoa();
                    updatePessoa = entities.pessoas.FirstOrDefault(up => up.cpf == p.cpf);

                    if (p.nome.Equals(null) || p.nome.Equals(""))
                    {
                        updatePessoa.nome = updatePessoa.nome;
                    }
                    else
                    {
                        updatePessoa.nome = p.nome;
                    }

                    if (p.sobrenome.Equals(null) || p.sobrenome.Equals(""))
                    {
                        updatePessoa.sobrenome = updatePessoa.sobrenome;
                    }
                    else
                    {
                        updatePessoa.sobrenome = p.sobrenome;
                    }

                    if (p.email.Equals(null) || p.email.Equals(""))
                    {
                        updatePessoa.email = updatePessoa.email;
                    }
                    else
                    {
                        updatePessoa.email = p.email;
                    }

                    if (p.idade.Equals(null) || p.idade.Equals(""))
                    {
                        updatePessoa.idade = updatePessoa.idade;
                    }
                    else
                    {
                        updatePessoa.idade = p.idade;
                    }

                    if (p.sexo.Equals(null) || p.sexo.Equals(""))
                    {
                        updatePessoa.sexo = updatePessoa.sexo;
                    }
                    else
                    {
                        updatePessoa.sexo = p.sexo;
                    }

                    if (p.senha.Equals(null) || p.senha.Equals(""))
                    {
                        updatePessoa.senha = updatePessoa.senha;
                    }
                    else
                    {
                        updatePessoa.senha = p.senha;
                    }

                    entities.SaveChanges();
                    return("Dados do Cadastro foram atualizados com sucesso!");
                }
                catch (Exception e)
                {
                    return("Erro: " + e.Message);
                }
            }
        }
コード例 #21
0
        public static string cadastrarPessoa(pessoa p)
        {
            using (LoginEntities entities = new LoginEntities())
            {
                try
                {
                    pessoa createPessoa = new pessoa();

                    bool cpfaux       = false;
                    bool nomeaux      = false;
                    bool sobrenomeaux = false;
                    bool emailaux     = false;
                    bool idadeaux     = false;
                    bool sexoaux      = false;
                    bool senhaaux     = false;

                    if (p.cpf.Equals(null) || p.cpf.Equals("") || p.cpf.Length < 11)
                    {
                        cpfaux = false;
                    }
                    else
                    {
                        createPessoa.cpf = p.cpf;
                        cpfaux           = true;
                    }

                    if (p.nome.Equals(null) || p.nome.Equals(""))
                    {
                        nomeaux = false;
                    }
                    else
                    {
                        createPessoa.nome = p.nome;
                        nomeaux           = true;
                    }

                    if (p.sobrenome.Equals(null) || p.sobrenome.Equals(""))
                    {
                        sobrenomeaux = false;
                    }
                    else
                    {
                        createPessoa.sobrenome = p.sobrenome;
                        sobrenomeaux           = true;
                    }

                    if (p.email.Equals(null) || p.email.Equals(""))
                    {
                        emailaux = true;
                    }
                    else
                    {
                        createPessoa.email = p.email;
                        emailaux           = true;
                    }

                    if (p.idade.Equals(null) || p.idade.Equals(""))
                    {
                        idadeaux = false;
                    }
                    else
                    {
                        createPessoa.idade = p.idade;
                        idadeaux           = true;
                    }

                    if (p.sexo.Equals(null) || p.sexo.Equals(""))
                    {
                        sexoaux = false;
                    }
                    else
                    {
                        createPessoa.sexo = p.sexo;
                        sexoaux           = true;
                    }

                    if (p.senha.Equals(null) || p.senha.Equals(""))
                    {
                        senhaaux = false;
                    }
                    else
                    {
                        createPessoa.senha = p.senha;
                        senhaaux           = true;
                    }


                    if (cpfaux == true && nomeaux == true && sobrenomeaux == true && emailaux == true && idadeaux == true && sexoaux == true && senhaaux == true)
                    {
                        entities.pessoas.Add(createPessoa);
                        entities.SaveChanges();
                        return("Cadastro realizado com sucesso!");
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return("Erro: " + e.Message);
                }
            }
        }
コード例 #22
0
        public ActionResult EditTask()
        {
            if (HttpContext.Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (Request.Form["can"] != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            string validate = "";

            if (Request.Form["tid"] == null || Request.Form["tid"].Trim() == "" || Request.Form["tname"] == null || Request.Form["tdesc"] == null || Request.Form["tdate"] == null ||
                Request.Form["tname"].Trim() == "" || Request.Form["tdesc"].Trim() == "" || Request.Form["tdate"].Trim() == "")
            {
                validate = "<div class='erralert'>Some fields are missing!</div>";
            }

            if (validate == "")
            {
                int id = 0;
                if (int.TryParse(Request.Form["tid"], out id))
                {
                    string usern = (string)HttpContext.Session["Username"];
                    ASPProjectRedux.Models.Task t = db.Tasks.First(x => x.usr == usern && x.Id == id);
                    if (t != null)
                    {
                        DateTime td = new DateTime();
                        t.name = Request.Form["tname"];
                        t.desc = Request.Form["tdesc"];
                        if (DateTime.TryParse(Request.Form["tdate"], out td))
                        {
                            t.date = td;
                            db.SaveChanges();
                        }
                        else
                        {
                            validate = "<div class='erralert'>Invalid date!</div>";
                        }
                    }
                    else
                    {
                        validate = "<div class='erralert'>Failed to update task!</div>";
                    }
                }
                else
                {
                    validate = "<div class='erralert'>Failed to update task!</div>";
                }
            }

            if (validate != "")
            {
                HttpCookie k = new HttpCookie("validatEdit", HttpUtility.UrlEncode(validate));
                k.Expires = DateTime.Now.AddSeconds(5);
                Response.Cookies.Add(k);
                return(RedirectToAction("Edit", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }