Exemple #1
0
        public void TestOnlyEnterContestTwice()
        {
            using (var db = new AcmeDBEntities())
            {
                var controller = new SubmissionsController();
                var submission = new Submission()
                {
                    FirstName = "a", LastName = "b", Email = "*****@*****.**", Age = 20, Serialnumber = Guid.Parse("0FBF023F9CB946E58B780E820EC815CD"), DOB = DateTime.Now.AddYears(-20)
                };

                controller.Create(submission);
                var serial = db.Serialnumber.FirstOrDefault(x => submission.Serialnumber == x.Serialnumber1);
                Assert.AreEqual(1, serial.Counter);

                //controller.Create(submission);
                //serial = db.Serialnumber.FirstOrDefault(x => submission.Serialnumber == x.Serialnumber1);
                //Assert.AreEqual(0, serial.Counter);

                //try
                //{
                //    controller.Create(submission);
                //    serial = db.Serialnumber.FirstOrDefault(x => submission.Serialnumber == x.Serialnumber1);
                //    Assert.Fail();
                //} catch (Exception e)
                //{

                //}
            }
        }
 public JsonResult IsUserNameAvailable(string FirstName)
 {
     using (var db = new AcmeDBEntities())
     {
         return(Json(!db.SubmissionSet.Any(name => name.FirstName == FirstName), JsonRequestBehavior.AllowGet));
     }
 }
 // GET: Submissions
 public ActionResult Index()
 {
     using (var db = new AcmeDBEntities())
     {
         var submissionSet = db.SubmissionSet.Include(s => s.Serialnumber1);
         return(View(submissionSet.ToList()));
     }
 }
Exemple #4
0
 public void Refresh()
 {
     _AcmeEntities               = new AcmeDBEntities();
     _BookingRepository          = null;
     _PassengerRepository        = null;
     _PassengerBookingRepository = null;
     _FlightRepository           = null;
     _ExceptionRepository        = null;
 }
        // GET: Submissions/Details/5
        //public ActionResult Details(int? id)
        //{
        //    using (var db = new AcmeDBEntities())
        //    {
        //        if (id == null)
        //        {
        //            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //        }
        //        Submission submission = db.SubmissionSet.Find(id);
        //        if (submission == null)
        //        {
        //            return HttpNotFound();
        //        }
        //        return View(submission);
        //    }
        //}

        // GET: Submissions/Create
        public ActionResult Create()
        {
            using (var db = new AcmeDBEntities())
            {
                ViewBag.Serialnumber = new SelectList(db.Serialnumber, "Serialnumber1", "Serialnumber1");



                return(View());
            }
        }
        public JsonResult IsSerialnumberAvailable(Guid?Serialnumber)
        {
            if (!Serialnumber.HasValue)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            using (var db = new AcmeDBEntities())
            {
                var serial = db.Serialnumber.FirstOrDefault(x => x.Serialnumber1 == Serialnumber);
                return(Json(serial.Counter > 0, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #7
0
 public Repository(AcmeDBEntities entities)
 {
     _Entity       = entities.Set <TEntity>();
     _AcmeEntities = entities;
 }