Ejemplo n.º 1
0
        public IActionResult RegisterDojo(Dojos NewDojo)
        {
            if (ModelState.IsValid)
            {
                Dojos RegisteredDojo = _context.Dojos.SingleOrDefault(i => i.DojoId == NewDojo.DojoId);
                if (RegisteredDojo != null)
                {
                    // ViewBag.Message = "This email exists. Please use a different email.";
                    ModelState.AddModelError("DojoName", "This ninja exists. Please choose a different name.");

                    return(View("Dojos"));
                }
                _context.Dojos.Add(NewDojo);
                _context.SaveChanges();
                NewDojo        = _context.Dojos.SingleOrDefault(i => i.DojoId == NewDojo.DojoId);
                ViewBag.Dojos  = _context.Dojos.Include(d => d.Ninjas).ToList();
                ViewBag.Ninjas = _context.Ninjas.Include(n => n.Dojos).ToList();
                HttpContext.Session.SetInt32("CurrentDojo", NewDojo.DojoId);
                int?CurrentDojoId = HttpContext.Session.GetInt32("CurrentDojo");
                ViewBag.CurrentDojo = NewDojo;
                // return RedirectToAction("Account", "Transactions", new{AccountId});
                return(RedirectToAction("Dojos", "Dojos"));
                //Handle success
            }
            ViewBag.Dojos  = _context.Dojos.Include(d => d.Ninjas).ToList();
            ViewBag.Ninjas = _context.Ninjas.Include(n => n.Dojos).ToList();
            return(View("Dojos"));
        }
Ejemplo n.º 2
0
        public Dojos Update(Dojos dojo)
        {
            Dojos result = null;

            string sql = " UPDATE tblDojos "
                         + " SET "
                         + " intIDPersonen           = @IDPersonen, "
                         + " strDojoName             = @DojoName, "
                         + " strBeschreibung         = @Beschreibung, "
                         + " strDojoUrl              = @DojoUrl, "
                         + " intDDLinkStatus         = @DDLinkStatus, "
                         + " intDDStilrichtung       = @DDStilrichtung, "
                         + " strPLZ                  = @PLZ, "
                         + " strOrt                  = @Ort, "
                         + " intDDBundesland         = @DDBundesland, "
                         + " intDDLand               = @DDLand, "
                         + " blnFreigegeben          = @Freigegeben, "
                         + " memInternerKommentar    = @InternerKommentar, "
                         + " dtmLastChanged          = @LastChanged, "
                         + " intIDLastChanged        = @IDLastChanged "
                         + " WHERE (IDDojos = @ID)";

            var parameters   = GetUpdateParameters(dojo);
            int affectedRows = Execute <Termine>(sql, parameters);

            if (affectedRows > 0)
            {
                result = Get(dojo.IDDojos);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void Get_ParameterID590_ReturnsOneDojos()
        {
            int id = 590;

            Dojos actual = _target.Get(id);

            Assert.IsNotNull(actual);
        }
Ejemplo n.º 4
0
        public void Get_ParameterID590_IsBudoClubKarlsruhe()
        {
            int    id       = 590;
            string expected = "Budo-Club Karlsruhe e.V.";

            Dojos actual = _target.Get(id);

            Assert.AreEqual(expected, actual.strDojoName);
        }
Ejemplo n.º 5
0
        public IActionResult Recruit(int NewDojoId, int NewNinjaId)
        {
            Ninjas NewNinja = _context.Ninjas.SingleOrDefault(n => n.NinjaId == NewNinjaId);
            Dojos  NewDojo  = _context.Dojos.SingleOrDefault(d => d.DojoId == NewDojoId);

            NewNinja.Dojos.DojoName = NewDojo.DojoName;
            _context.SaveChanges();
            return(RedirectToAction("Show", new { DojoId = NewDojoId }));
        }
Ejemplo n.º 6
0
        public IActionResult DojoPage(int NewDojoId)
        {
            Dojos NewDojo = _context.Dojos.Where(n => n.DojoId == NewDojoId).Include(n => n.Ninjas).SingleOrDefault();

            ViewBag.Dojos       = NewDojo;
            ViewBag.DojoMembers = _context.Ninjas.Include(n => n.Dojos).Where(n => n.Dojos.DojoId == NewDojoId).ToList();
            ViewBag.RogueNinjas = _context.Ninjas.Include(n => n.Dojos).Where(n => n.Dojos.DojoId == 0).ToList();
            return(View("Show"));
        }
Ejemplo n.º 7
0
        public void Insert_NewDojo_DojoWasInserted()
        {
            string expected = "Test DojoName";


            Dojos actual = _target.Insert(_TestDojo);

            Assert.AreEqual(expected, actual.strDojoName);

            _target.Delete(_TestDojo.IDDojos);
        }
Ejemplo n.º 8
0
        public void Update_InsertAndUpdate_WasUpdatedInDatabase()
        {
            var expected = "Test DojoName Update";
            var dojo     = _target.Insert(_TestDojo);

            dojo.strDojoName = "Test DojoName Update";
            dojo.strOrt      = "Test Ort Update";

            Dojos updated = _target.Update(dojo);

            var actual = _target.Get(updated.IDDojos);

            Assert.AreEqual(expected, actual.strDojoName);
        }
Ejemplo n.º 9
0
        public Dojos Insert(Dojos dojo)
        {
            if (dojo == null)
            {
                throw new ArgumentNullException(nameof(dojo));
            }
            if (dojo.IDDojos != 0)
            {
                throw new ArgumentException(nameof(dojo.IDDojos));
            }

            Dojos  result   = null;
            var    saveDate = DateTime.Now.ToOADate();
            string sql      = " Insert INTO tblDojos "
                              + " (intIDPersonen, strDojoName, strBeschreibung, strDojoUrl, intDDLinkStatus, intDDStilrichtung, strPLZ, strOrt, intDDBundesland, intDDLand, blnFreigegeben, memInternerKommentar, dtmLastChanged, intIDLastChanged, dtmErstAm, intIDErstVon) "
                              + " VALUES (@IDPersonen, @DojoName, @Beschreibung, @DojoUrl, @DDLinkStatus, @DDStilrichtung, @PLZ, @Ort, @DDBundesland, @DDLand, @Freigegeben, @InternerKommentar, @LastChanged, @IDLastChanged, @ErstAm, @IDErstVon ) ";
            var parameter = new
            {
                IDPersonen        = dojo.intIDPersonen,
                DojoName          = dojo.strDojoName,
                Beschreibung      = dojo.strBeschreibung,
                DojoUrl           = dojo.strDojoUrl,
                DDLinkStatus      = dojo.intDDLinkStatus,
                DDStilrichtung    = dojo.intDDStilrichtung,
                PLZ               = dojo.strPLZ,
                Ort               = dojo.strOrt,
                DDBundesland      = dojo.intDDBundesland,
                DDLand            = dojo.intDDLand,
                Freigegeben       = dojo.blnFreigegeben,
                InternerKommentar = dojo.memInternerKommentar,
                LastChanged       = saveDate,
                IDLastChanged     = dojo.intIDLastChanged,
                ErstAm            = saveDate,
                IDErstVon         = dojo.intIDErstVon
            };
            var rowsaffected = Execute <Dojos>(sql, parameter);

            if (rowsaffected > 0)
            {
                var select = " SELECT TOP 1 * "
                             + " FROM tblDojos "
                             + " WHERE dtmErstAm = @Saved AND dtmLastChanged = @Saved "
                             + " ORDER BY IDDojos DESC";
                var parameter2 = new { Saved = saveDate };

                result = Query <Dojos>(select, parameter2).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 10
0
 public void SetUp()
 {
     _target   = new DojosRepository();
     _TestDojo = new Dojos
     {
         intIDPersonen     = 1,
         strDojoName       = "Test DojoName",
         intDDLinkStatus   = 50,
         intDDStilrichtung = 0, //93,
         intDDBundesland   = 0,
         intDDLand         = 0,
         intIDLastChanged  = 1,
         intIDErstVon      = 1
     };
 }
Ejemplo n.º 11
0
        private DynamicParameters GetUpdateParameters(Dojos dojo)
        {
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("IDPersonen", dojo.intIDPersonen);
            parameters.Add("DojoName", dojo.strDojoName);
            parameters.Add("Beschreibung", dojo.strBeschreibung);
            parameters.Add("DojoUrl", dojo.strDojoUrl);
            parameters.Add("DDLinkStatus", dojo.intDDLinkStatus);
            parameters.Add("DDStilrichtung", dojo.intDDStilrichtung);
            parameters.Add("PLZ", dojo.strPLZ);
            parameters.Add("Ort", dojo.strOrt);
            parameters.Add("DDBundesland", dojo.intDDBundesland);
            parameters.Add("DDLand", dojo.intDDLand);
            parameters.Add("Freigegeben", dojo.blnFreigegeben);
            parameters.Add("InternerKommentar", dojo.memInternerKommentar);
            parameters.Add("LastChanged", DateTime.Now.ToOADate());
            parameters.Add("IDLastChanged", dojo.intIDLastChanged);
            parameters.Add("ID", dojo.IDDojos);

            return(parameters);
        }
Ejemplo n.º 12
0
        public void Ctor_NewInstance_ImplementsIEntity()
        {
            var target = new Dojos();

            Assert.IsNotNull(target as IEntity);
        }