示例#1
0
        async void ChangeImageSource(ImageSource source)
        {
            await CheckImage.ScaleTo(1.30d, 80, Easing.Linear);

            CheckImage.Source = source;
            await CheckImage.ScaleTo(1.0d, 80, Easing.Linear);
        }
示例#2
0
        public void TestImage_Size_LessThan_100kb_Result_True()
        {
            CheckImage checkImage = new CheckImage();
            long       FileSize   = 1000;
            bool       result     = checkImage.checkSize(FileSize);

            Assert.True(result);
        }
示例#3
0
        public void TestImage_Extension_PNG_JPEG_Result_True(string extension)
        {
            CheckImage checkImage = new CheckImage();
            string     FileName   = $"testImage.{extension}";
            bool       result     = checkImage.checkExtension(FileName);

            Assert.True(result);
        }
示例#4
0
        public ActionResult Create([Bind(Include = "LastName, FirstMidName, EnrollmentDate")] Student student, HttpPostedFileBase upload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                        //getting the image
                        string fileName = System.IO.Path.GetExtension(upload.FileName);
                        //call of the verification class CheckImage
                        CheckImage check = new CheckImage();

                        //call of the verification Extension method
                        bool extensionIsTrue = check.checkExtension(fileName);

                        if (extensionIsTrue == false)
                        {
                            ViewBag.ErrorExtension = ErrorMessages.ErrorExtension();
                            return(View());
                        }


                        //call of the verfication Size method
                        bool sizeIsCorrect = check.checkSize(upload.ContentLength);

                        if (sizeIsCorrect == false)
                        {
                            ViewBag.ErrorSize = ErrorMessages.ErrorSize();
                            return(View());
                        }

                        var avatar = new FileImage
                        {
                            FileName    = Path.GetFileName(upload.FileName),
                            FileType    = FileType.Avatar,
                            ContentType = upload.ContentType
                        };
                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            avatar.Content = reader.ReadBytes(upload.ContentLength);
                        }
                        student.Files = new List <FileImage> {
                            avatar
                        };
                    }
                    db.Students.Add(student);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(student));
        }
        void ReleaseDesignerOutlets()
        {
            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (CheckImage != null)
            {
                CheckImage.Dispose();
                CheckImage = null;
            }
        }
示例#6
0
        public ActionResult Edit(int?id, string[] selectedCourses, HttpPostedFileBase upload)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var instructorToUpdate = db.Instructors
                                     .Include(i => i.OfficeAssignment)
                                     .Include(i => i.Courses)
                                     .Where(i => i.ID == id)
                                     .Single();

            if (TryUpdateModel(instructorToUpdate, "",
                               new string[] { "LastName", "FirstMidName", "HireDate", "OfficeAssignment" }))
            {
                try
                {
                    if (String.IsNullOrWhiteSpace(instructorToUpdate.OfficeAssignment.Location))
                    {
                        instructorToUpdate.OfficeAssignment = null;
                    }

                    UpdateInstructorCourses(selectedCourses, instructorToUpdate);
                    if (upload != null && upload.ContentLength > 0)
                    {
                        #region CheckImage
                        CheckImage check = new CheckImage();
                        //getting the image
                        string fileName = System.IO.Path.GetExtension(upload.FileName);
                        //call of the verification Extension method
                        bool extensionIsTrue = check.checkExtension(fileName);

                        if (extensionIsTrue == false)
                        {
                            ViewBag.ErrorType = ErrorMessages.ErrorExtension();
                            Instructor instructor = db.Instructors
                                                    .Include(s => s.FileImage)
                                                    .Include(i => i.OfficeAssignment)
                                                    .Include(i => i.Courses)
                                                    .Where(i => i.ID == id)
                                                    .Single();
                            PopulateAssignedCourseData(instructor);
                            return(View(instructor));
                        }

                        //call of the verfication Size method
                        bool sizeIsCorrect = check.checkSize(upload.ContentLength);

                        if (sizeIsCorrect == false)
                        {
                            ViewBag.ErrorSize = ErrorMessages.ErrorSize();
                            Instructor instructor = db.Instructors
                                                    .Include(s => s.FileImage)
                                                    .Include(i => i.OfficeAssignment)
                                                    .Include(i => i.Courses)
                                                    .Where(i => i.ID == id)
                                                    .Single();
                            PopulateAssignedCourseData(instructor);
                            return(View(instructor));
                        }
                        #endregion
                        //Remove the the previous image
                        if (instructorToUpdate.FileImage.Any(f => f.FileType == FileType.Avatar))
                        {
                            db.FileImages.Remove(instructorToUpdate.FileImage.First(f => f.FileType == FileType.Avatar));
                        }

                        UploadImage uploadImage = new UploadImage();
                        FileImage   avatar      = uploadImage.Upload(upload);

                        instructorToUpdate.FileImage = new List <FileImage> {
                            avatar
                        };
                    }
                    db.Entry(instructorToUpdate).State = EntityState.Modified;

                    db.SaveChanges();

                    return(View(viewName: "Details", model: instructorToUpdate));
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            PopulateAssignedCourseData(instructorToUpdate);
            return(View(instructorToUpdate));
        }
示例#7
0
 public X9Rec(string recType, string recData, string recImage, CheckImage imageType, byte[] imageData) :
     this(recType, recData, recImage)
 {
     CheckImageType = imageType;
     ImageData      = imageData;
 }
示例#8
0
        public ActionResult EditPost(int?id, HttpPostedFileBase upload)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var studentToUpdate = db.Students.Find(id);

            if (TryUpdateModel(studentToUpdate, "",
                               new string[] { "LastName", "FirstMidName", "EnrollmentDate" }))
            {
                try
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                        //string typeFile = Path.GetExtension(upload.FileName);
                        CheckImage check = new CheckImage();
                        //getting the image
                        string fileName = System.IO.Path.GetExtension(upload.FileName);

                        //call of the verification Extension method
                        bool extensionIsTrue = check.checkExtension(fileName);

                        if (extensionIsTrue == false)
                        {
                            ViewBag.ErrorType = ErrorMessages.ErrorExtension();
                            Student student = db.Students.Include(s => s.Files).SingleOrDefault(s => s.ID == id);
                            return(View(student));
                        }

                        //call of the verfication Size method
                        bool sizeIsCorrect = check.checkSize(upload.ContentLength);

                        if (sizeIsCorrect == false)
                        {
                            ViewBag.ErrorSize = ErrorMessages.ErrorSize();
                            Student student = db.Students.Include(s => s.Files).SingleOrDefault(s => s.ID == id);
                            return(View(student));
                        }

                        //Remove the the previous image
                        if (studentToUpdate.Files.Any(f => f.FileType == FileType.Avatar))
                        {
                            db.Files.Remove(studentToUpdate.Files.First(f => f.FileType == FileType.Avatar));
                        }

                        var avatar = new FileImage
                        {
                            FileName    = System.IO.Path.GetFileName(upload.FileName),
                            FileType    = FileType.Avatar,
                            ContentType = upload.ContentType
                        };

                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            avatar.Content = reader.ReadBytes(upload.ContentLength);
                        }
                        studentToUpdate.Files = new List <FileImage> {
                            avatar
                        };
                    }

                    db.Entry(studentToUpdate).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            return(View(studentToUpdate));
        }
示例#9
0
 public CorrectedPage(string fileName, int id = -1)
 {
     ID         = id;
     FileName   = fileName;
     CheckImage = new CheckImage(FileName);
 }
示例#10
0
 public void Dispose()
 {
     CheckImage.Dispose();
     CheckImage = null;
 }
示例#11
0
        public void InitializeDatabase(BankContext context)
        {
            Crypto crypto = new Crypto();
            bool   dbExists;

            dbExists = context.Database.Exists();
            if (dbExists)
            {
                Bank bank = context.Banks.Where(b => b.bankName == "KSJ Bank").FirstOrDefault <Bank>();
                if (bank == null)
                {
                    context.Banks.Add(new Bank()
                    {
                        bankName = "KSJ Bank", bankAddress = "1 Bank Street, New York, New York"
                    });
                    Customer customerKen = new Customer()
                    {
                        customerName = "Ken Dinsmore", address = "123 Main Street, San Antonio TX", phone = "210-555-5555", email = "*****@*****.**", customerIdStatus = "V"
                    };
                    Customer customerSangam = new Customer()
                    {
                        customerName = "Sangam Sahai ", address = "#2 Tech Street, Lubbock TX", phone = "555-5555", email = "*****@*****.**", customerIdStatus = "V"
                    };
                    Customer customerJayson = new Customer()
                    {
                        customerName = "Jayson Brown", address = "#42 Prefect Lane, Vogon TX", phone = "259-555-1234", email = "*****@*****.**", customerIdStatus = "V"
                    };
                    context.Customers.Add(customerKen);
                    context.Customers.Add(customerSangam);
                    context.Customers.Add(customerJayson);
                    context.SaveChanges();

                    CheckingAccount checkingAccountKen = new CheckingAccount()
                    {
                        accountNumber = crypto.Encrypt("Ken-123C"), balance = 700, customerID = customerKen.customerID, isChecking = true, lastDepositAmount = 0
                    };
                    SavingsAccount savingsAccountKen = new SavingsAccount()
                    {
                        accountNumber = crypto.Encrypt("Ken-123S"), balance = 300, customerID = customerKen.customerID, isChecking = false, Interest = 100
                    };
                    context.CheckingAccounts.Add(checkingAccountKen);
                    context.SavingsAccounts.Add(savingsAccountKen);

                    TransferTransaction transferTransactionKen1 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("External"), toAccountNumber = crypto.Encrypt("Ken-123C"), amount = 1000, dateTime = DateTime.Parse("1 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionKen2 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Ken-123C"), toAccountNumber = crypto.Encrypt("Ken-123S"), amount = 100, dateTime = DateTime.Parse("5 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionKen3 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Ken-123C"), toAccountNumber = crypto.Encrypt("Ken-123S"), amount = 100, dateTime = DateTime.Parse("12 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionKen4 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Ken-123S"), toAccountNumber = crypto.Encrypt("Ken-123C"), amount = 100, dateTime = DateTime.Parse("19 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionKen5 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Ken-123C"), toAccountNumber = crypto.Encrypt("Ken-123S"), amount = 200, dateTime = DateTime.Parse("19 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    context.TransferTransactions.Add(transferTransactionKen1);
                    context.TransferTransactions.Add(transferTransactionKen2);
                    context.TransferTransactions.Add(transferTransactionKen3);
                    context.TransferTransactions.Add(transferTransactionKen4);
                    context.TransferTransactions.Add(transferTransactionKen5);

                    CheckingAccount checkingAccountSangam = new CheckingAccount()
                    {
                        accountNumber = crypto.Encrypt("Sangam-123C"), balance = 70, customerID = customerSangam.customerID, isChecking = true, lastDepositAmount = 0
                    };
                    SavingsAccount savingsAccountSangam = new SavingsAccount()
                    {
                        accountNumber = crypto.Encrypt("Sangam-123S"), balance = 30, customerID = customerSangam.customerID, isChecking = false, Interest = 5
                    };
                    context.CheckingAccounts.Add(checkingAccountSangam);
                    context.SavingsAccounts.Add(savingsAccountSangam);

                    TransferTransaction transferTransactionSangam1 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("External"), toAccountNumber = crypto.Encrypt("Sangam-123C"), amount = 100, dateTime = DateTime.Parse("2 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionSangam2 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Sangam-123C"), toAccountNumber = crypto.Encrypt("Sangam-123S"), amount = 10, dateTime = DateTime.Parse("3 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionSangam3 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Sangam-123C"), toAccountNumber = crypto.Encrypt("Sangam-123S"), amount = 10, dateTime = DateTime.Parse("7 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionSangam4 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Sangam-123S"), toAccountNumber = crypto.Encrypt("Sangam-123C"), amount = 10, dateTime = DateTime.Parse("12 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionSangam5 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Sangam-123C"), toAccountNumber = crypto.Encrypt("Sangam-123S"), amount = 20, dateTime = DateTime.Parse("15 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    context.TransferTransactions.Add(transferTransactionSangam1);
                    context.TransferTransactions.Add(transferTransactionSangam2);
                    context.TransferTransactions.Add(transferTransactionSangam3);
                    context.TransferTransactions.Add(transferTransactionSangam4);
                    context.TransferTransactions.Add(transferTransactionSangam5);

                    CheckingAccount checkingAccountJayson = new CheckingAccount()
                    {
                        accountNumber = crypto.Encrypt("Jayson-123C"), balance = 0, customerID = customerJayson.customerID, isChecking = true, lastDepositAmount = 0
                    };
                    SavingsAccount savingsAccountJayson = new SavingsAccount()
                    {
                        accountNumber = crypto.Encrypt("Jayson-123S"), balance = 0, customerID = customerJayson.customerID, isChecking = false, Interest = 1
                    };
                    context.CheckingAccounts.Add(checkingAccountJayson);
                    context.SavingsAccounts.Add(savingsAccountJayson);
                    context.SaveChanges();

                    TransferTransaction transferTransactionJayson1 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("External"), toAccountNumber = crypto.Encrypt("Jayson-123C"), amount = 10, dateTime = DateTime.Parse("3 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionJayson2 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Jayson-123C"), toAccountNumber = crypto.Encrypt("Jayson-123S"), amount = 1, dateTime = DateTime.Parse("4 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionJayson3 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Jayson-123C"), toAccountNumber = crypto.Encrypt("Jayson-123S"), amount = 1, dateTime = DateTime.Parse("6 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionJayson4 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Jayson-123S"), toAccountNumber = crypto.Encrypt("Jayson-123C"), amount = 1, dateTime = DateTime.Parse("14 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    TransferTransaction transferTransactionJayson5 = new TransferTransaction()
                    {
                        fromAccountNumber = crypto.Encrypt("Jayson-123C"), toAccountNumber = crypto.Encrypt("Jayson-123S"), amount = 2, dateTime = DateTime.Parse("17 Jan 2015"), transactionType = Transaction.TransactionType.Transfer, status = "Success"
                    };
                    context.TransferTransactions.Add(transferTransactionJayson1);
                    context.TransferTransactions.Add(transferTransactionJayson2);
                    context.TransferTransactions.Add(transferTransactionJayson3);
                    context.TransferTransactions.Add(transferTransactionJayson4);
                    context.TransferTransactions.Add(transferTransactionJayson5);

                    Alert alertKen = new Alert()
                    {
                        accountNumber = checkingAccountKen.accountNumber, alertData = "Balance < 1,000,000"
                    };
                    Alert alertSangam = new Alert()
                    {
                        accountNumber = checkingAccountSangam.accountNumber, alertData = "Balance < 1,000"
                    };
                    Alert alertJayson = new Alert()
                    {
                        accountNumber = checkingAccountJayson.accountNumber, alertData = "Balance < 1"
                    };
                    context.Alerts.Add(alertKen);
                    context.Alerts.Add(alertSangam);
                    context.Alerts.Add(alertJayson);

                    CheckImage checkImage100 = new CheckImage()
                    {
                        accountNumber = crypto.Encrypt("Ken-123C"), checkNumber = "1", checkImage = "\\img\\check100.jpg"
                    };
                    CheckImage checkImage10 = new CheckImage()
                    {
                        accountNumber = crypto.Encrypt("Sangam-123C"), checkNumber = "1", checkImage = "\\img\\check10.jpg"
                    };
                    CheckImage checkImage1 = new CheckImage()
                    {
                        accountNumber = crypto.Encrypt("Jayson-123C"), checkNumber = "1", checkImage = "\\img\\check1.jpg"
                    };
                    context.CheckImages.Add(checkImage100);
                    context.CheckImages.Add(checkImage10);
                    context.CheckImages.Add(checkImage1);
                    context.SaveChanges();
                }
            }
        }