Beispiel #1
0
        public ActionResult ChangePassword([Bind(Include = "Id,Username,Password,UserType")] Login checkuser, string changepassword, string confirmpassword)
        {
            using (FileSystemContext db = new FileSystemContext())
            {
                var DoesUserExist = db.Logins.Where(x => x.Username == checkuser.Username && x.Password == checkuser.Password).FirstOrDefault();

                if (DoesUserExist != null)
                {
                    if (changepassword == confirmpassword)
                    {
                        checkuser.Password            = confirmpassword;
                        DoesUserExist.Password        = checkuser.Password;
                        db.Entry(DoesUserExist).State = EntityState.Modified;


                        db.SaveChanges();
                        TempData["Msg"] = "Password Change Successfully.";
                        return(RedirectToAction("Login", "Account"));
                    }
                    else
                    {
                        TempData["Message"] = "Confirm Password Do Not Match.";
                        return(View());
                    }
                }
                else
                {
                    TempData["Message"] = "Username or Password Does Not Match or Exist.";
                    return(View());
                }
            }
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "Id,Username,Password,UserType,CurrentSO,PreviousSO,Dateofjoining")] Login login)
 {
     if (ModelState.IsValid)
     {
         db.Entry(login).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(login));
 }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "FileDataDetailId,FileDataId,FilePath,Status,UploadTime")] FileDataDetail fileDataDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fileDataDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FileDataId = new SelectList(db.FileDatas, "FileDataId", "Date", fileDataDetail.FileDataId);
     return(View(fileDataDetail));
 }
Beispiel #4
0
        public void CanInsertDirectoryIntoDatabase()
        {
            builder.UseInMemoryDatabase("CanInsertDirectory");

            using (var context = new FileSystemContext(builder.Options))
            {
                var dir = new Directory();
                context.Directories.Add(dir);

                //Check the state of the entity is 'added'.
                Assert.Equal(EntityState.Added, context.Entry(dir).State);
            }
        }
Beispiel #5
0
        public void CanInsertFileIntoDatabase()
        {
            builder.UseInMemoryDatabase("CanInsertFile");

            using (var context = new FileSystemContext(builder.Options))
            {
                var file = new File()
                {
                    DirectoryId = 1
                };
                context.Files.Add(file);

                //Check the state of the entity is 'added'.
                Assert.Equal(EntityState.Added, context.Entry(file).State);
            }
        }
Beispiel #6
0
        public void CanRemoveDirectoryFromDatabase()
        {
            builder.UseInMemoryDatabase("CanDeleteDirectory");

            using (var context = new FileSystemContext(builder.Options))
            {
                var dir = new Directory()
                {
                    Name = "DeleteDirectory"
                };

                context.Directories.Add(dir);
                context.Directories.Remove(dir);

                Assert.Equal(EntityState.Detached, context.Entry(dir).State);
            }
        }
Beispiel #7
0
        public void CanRemoveFileFromDatabase()
        {
            builder.UseInMemoryDatabase("CanDeleteFile");

            using (var context = new FileSystemContext(builder.Options))
            {
                var file = new File()
                {
                    Name = "DeleteFile", DirectoryId = 1
                };

                context.Files.Add(file);
                context.Files.Remove(file);

                Assert.Equal(EntityState.Detached, context.Entry(file).State);
            }
        }