コード例 #1
0
        public void testGivenCourse()
        {
            const int assignid1 = 2;
            const int assignid2 = 1;
            const int assignid3 = 4;


            // act

            var result1 = _service.givenCourse(assignid1);
            var result2 = _service.givenCourse(assignid2);
            var result3 = _service.givenCourse(assignid3);

            // assert

            Assert.AreEqual("Gagnaskipan", result1);
            Assert.AreEqual("Forritun", result2);
            Assert.AreEqual("Stærðfræði", result3);
        }
コード例 #2
0
        public ActionResult UploadStatus(HttpPostedFileBase file, int id)
        {
            ViewBag.assId = id;
            //var userName = User.Identity.Name;

            // Specify the directory you want to manipulate.
            //string path = @"c:\MyDir";
            var assignment = aService.getAssignmentByID(id);
            var course     = aService.givenCourse(id);

            string path = Server.MapPath("~/Files/" + User.Identity.Name + "/" + course + "/" + assignment.name + "/");

            try
            {
                if (!Directory.Exists(path))
                {
                    // Try to create the directory.
                    DirectoryInfo di = Directory.CreateDirectory(path);
                    Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));
                }
                // Determine whether the directory exists.
                if (Directory.Exists(path))
                {
                    file.SaveAs(path + file.FileName);
                    ViewBag.Path = path;
                    //Console.WriteLine("That path exists already.");
                    //return;
                }

                // Try to create the directory.
                //DirectoryInfo di = Directory.CreateDirectory(path);
                //Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));

                // Delete the directory.
                //di.Delete();
                //Console.WriteLine("The directory was deleted successfully.");
            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
            finally { }


            //return View();
            return(View("Details"));
        }