Ejemplo n.º 1
0
        public async Task <ActionResult> ChangePassword(PasswordChange std)
        {
            await Task.Delay(0);

            Response res = new Response();
            var      Id  = EncryptionDecryption.Decrypt(std.id);

            DataTable table = SQLDatabase.GetDataTable("SELECT * FROM users WHERE Id='" + Id + "' AND Password='******'");

            if (table.Rows.Count > 0)
            {
                if (SQLDatabase.ExecNonQuery("update users set Password='******' where Id='" + Id + "'") > 0)
                {
                    res.Status = "Password Update Successfully";
                }
                else
                {
                    res.Status = "Password Updation Failed";
                }
            }
            else
            {
                res.Status = "Old Password is Incorrect";
            }

            return(Ok(res));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> DeleteUser(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            var Deactivebyid = std.Deactivebyid;

            if (Deactivebyid == "" || Deactivebyid == null)
            {
                Deactivebyid = std.Deactivebyid;
            }
            else
            {
                Deactivebyid = EncryptionDecryption.Decrypt(std.Deactivebyid);
            }
            res.id = std.Id;
            if (SQLDatabase.ExecNonQuery("update users set Status=0, DeactiveDateTime='" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "', Deactivebyid='" + Deactivebyid + "' where Id=" + std.Id) > 0)
            {
                res.Status = "Delete Successfully";
            }
            else
            {
                res.Status = "Deletion Failed";
            }

            return(Ok(res));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> UserProfile(Students std)
        {
            await Task.Delay(0);

            Response  res   = new Response();
            var       Id    = EncryptionDecryption.Decrypt(std.str1);
            DataTable table = SQLDatabase.GetDataTable("select Name,FatherName,Email,PhoneNumber,Gender,Address,Username from users where Id=" + Id + "");

            return(Ok(table));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> InsertData(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            DataTable table = SQLDatabase.GetDataTable("select* from users where Email='" + std.Email + "'");

            if (table.Rows.Count > 0)
            {
                res.Status = "Email Matched";
            }
            else
            {
                DataTable table1 = SQLDatabase.GetDataTable("select* from users where Username='******'");

                if (table1.Rows.Count > 0)
                {
                    res.Status = "Username Matched";
                }
                else
                {
                    var UserImage = "/assets/img/faces/card-profile1-square.jpg";

                    var Insertedbyid = std.Insertedbyid;

                    if (Insertedbyid == "" || Insertedbyid == null)
                    {
                        Insertedbyid = std.Insertedbyid;
                    }
                    else
                    {
                        Insertedbyid = EncryptionDecryption.Decrypt(std.Insertedbyid);
                    }

                    if (SQLDatabase.ExecNonQuery("insert into users (Name,FatherName,PhoneNumber,Email,Gender,Address,Username,Password,Image,Status,InsertedDateTime,Insertedbyid) values ('" + std.Name + "','" + std.FatherName + "','" + std.PhoneNumber + "','" + std.Email + "','" + std.Gender + "','" + std.Address + "','" + std.Username + "','" + EncryptionDecryption.Encrypt(std.Password) + "','" + UserImage + "',1,'" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','" + Insertedbyid + "')") > 0)
                    {
                        res.Status = "Inserted Successfully";
                    }
                    else
                    {
                        res.Status = "Insertion failed";
                    }
                }
            }
            return(Ok(res));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> UpdateUser(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            if (SQLDatabase.ExecNonQuery("update users set Name='" + std.Name + "',FatherName='" + std.FatherName + "',PhoneNumber='" + std.PhoneNumber + "',Email='" + std.Email + "',Gender='" + std.Gender + "',Address='" + std.Address + "'  where Id=" + std.Id) > 0)
            {
                res.Status = "Updated Successfully";
            }
            else
            {
                res.Status = "Updation Failed";
            }

            return(Ok(res));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Login(Students std)
        {
            await Task.Delay(0);

            Response  res   = new Response();
            DataTable table = SQLDatabase.GetDataTable("SELECT * FROM users where Username='******' and Password='******' and Status='1'");

            if (table.Rows.Count > 0)
            {
                res.Status = "Successfully Login";
                string Id = table.Rows[0]["Id"].ToString();

                res.str1 = EncryptionDecryption.Encrypt(Id);
            }
            else
            {
                res.Status = "Invalid UserName/Password";
            }
            return(Ok(res));
        }