コード例 #1
0
        // GET: Initiatives1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Initiatives          initiative = db.Initiatives.Find(id);
            InitiativesViewModel init       = new InitiativesViewModel()
            {
                UtilisateurID         = initiative.UtilisateurID,
                Nom_init              = initiative.Nom_init,
                Statu_init            = initiative.Statu_init.Value,
                Date_debu             = initiative.Date_debu.Value,
                Date_fin              = initiative.Date_fin.Value,
                Objectifs_generaux    = initiative.Objectifs_generaux,
                Obgectifs_specifiques = initiative.Obgectifs_specifiques,
                Description_court     = initiative.Description_court,
                Description_detaillee = initiative.Description_detaillee,
                Budget        = initiative.Budget.Value,
                Approbateur   = initiative.Approbateur,
                Cofinancement = initiative.Cofinancement,
                Regions       = initiative.Regions,
            };

            if (initiative == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
            return(View(init));
        }
コード例 #2
0
        public IHttpActionResult PostInitiatives(Initiatives initiatives)
        {
            try
            {
                if (initiatives == null)
                {
                    //return Ok(new { success = 0, errormessage = "No data found!" });
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest)));
                }
                else
                {
                    List <Initiatives> tmp = new List <Initiatives>();
                    tmp.Add(initiatives);

                    List <Initiatives> i = dblayer.PostInitiatives(tmp);
                }
            }
            catch (Exception ex)
            {
                dblayer.Error_Insert(ex.ToString(), "PostInitiatives");
                //return Ok(new { success = 0, errormessage = "Oops. Something went wrong" });
                //return ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, new { errormessage = "No data found", success = 0 }));
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest)));
            }
            //return Ok(new { success = 1, errormessage = "" });
            //return ResponseMessage(Request.CreateResponse(HttpStatusCode.OK));
            return(Json(initiatives));
        }
コード例 #3
0
ファイル: TurnManager.cs プロジェクト: cvance5/syphermia
    public static void GenerateInitiativeOrder(List <ArmyData> armiesInPlay)
    {
        Initiatives.Clear();

        foreach (ArmyData army in armiesInPlay)
        {
            foreach (CharacterData character in army.CharactersInArmy)
            {
                int initative = character.RollInitiative();

                if (Initiatives.Characters.Count == 0)
                {
                    Initiatives.Add(character, initative);
                }
                else
                {
                    bool wasPlaced = false;
                    for (int i = 0; i < Initiatives.Characters.Count; i++)
                    {
                        if (Initiatives[i] < initative)
                        {
                            Initiatives.Insert(i, character, initative);
                            wasPlaced = true;
                            break;
                        }
                    }
                    if (wasPlaced == false)
                    {
                        Initiatives.Add(character, initative);
                    }
                }
            }
        }
    }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Initiatives initiative = db.Initiatives.Find(id);

            db.Initiatives.Remove(initiative);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public ActionResult UpdateStatu(int id)
        {
            Initiatives ini = db.Initiatives.Find(id);

            ini.Statu_init = !ini.Statu_init.Value;
            db.Initiatives.Attach(ini);
            db.Entry(ini).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ID,UtilisateurID,Nom_init,Statu_init,Date_debu,Date_fin,Objectifs_generaux,Obgectifs_specifiques,Description_court,Description_detaillee,Budget,Approbateur,Cofinancement,Regions")] Initiatives initiative)
 {
     if (ModelState.IsValid)
     {
         initiative.Statu_init      = initiative.Statu_init;
         db.Entry(initiative).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
     return(View(initiative));
 }
コード例 #7
0
        // GET: Initiatives1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Initiatives initiative = db.Initiatives.Find(id);

            if (initiative == null)
            {
                return(HttpNotFound());
            }
            return(View(initiative));
        }
コード例 #8
0
ファイル: TurnManager.cs プロジェクト: cvance5/syphermia
 public static void TickTurns()
 {
     Debug.Assert(Initiatives.Count > 0, "Error!  Battle initiated with 0 armies and troops!");
     {
         if (Initiatives.PeekInitiative() < 100)
         {
             Initiatives.Advance();
         }
         else
         {
             CharacterData currentCharacter = Initiatives.Pop();
             BattleManager.ControlCharacter(currentCharacter);
         }
     }
 }
コード例 #9
0
        // GET: Initiatives1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Initiatives initiative = db.Initiatives.Find(id);

            if (initiative == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
            return(View(initiative));
        }
コード例 #10
0
 public ActionResult Edit(InitiativesViewModel initiative)
 {
     if (ModelState.IsValid)
     {
         try {
             //initiative.Statu_init = initiative.Statu_init;
             Initiatives init = new Initiatives()
             {
                 ID                    = initiative.ID,
                 UtilisateurID         = initiative.UtilisateurID,
                 Nom_init              = initiative.Nom_init,
                 Statu_init            = initiative.Statu_init,
                 Date_debu             = initiative.Date_debu,
                 Date_fin              = initiative.Date_fin,
                 Objectifs_generaux    = initiative.Objectifs_generaux,
                 Obgectifs_specifiques = initiative.Obgectifs_specifiques,
                 Description_court     = initiative.Description_court,
                 Description_detaillee = initiative.Description_detaillee,
                 Budget                = initiative.Budget,
                 Approbateur           = initiative.Approbateur,
                 Cofinancement         = initiative.Cofinancement,
                 Regions               = initiative.Regions,
             };
             db.Entry(init).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception DbExc)
         {
             //DbEntityValidationException
             //string error = "";
             //foreach (var er in DbExc.EntityValidationErrors)
             //{
             //    foreach (var ve in er.ValidationErrors)
             //    {
             //        error += " - " + ve.ErrorMessage;
             //    }
             //}
             TempData["Message"]   = DbExc.Message;
             ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
             return(View(initiative));
         }
     }
     ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
     return(View(initiative));
 }
コード例 #11
0
        public ActionResult Create(InitiativesViewModel initiative)
        {
            if (ModelState.IsValid)
            {
                try {
                    initiative.Statu_init = false;
                    Initiatives init = new Initiatives()
                    {
                        UtilisateurID         = initiative.UtilisateurID,
                        Nom_init              = initiative.Nom_init,
                        Statu_init            = initiative.Statu_init,
                        Date_debu             = initiative.Date_debu,
                        Date_fin              = initiative.Date_fin,
                        Objectifs_generaux    = initiative.Objectifs_generaux,
                        Obgectifs_specifiques = initiative.Obgectifs_specifiques,
                        Description_court     = initiative.Description_court,
                        Description_detaillee = initiative.Description_detaillee,
                        Budget        = initiative.Budget,
                        Approbateur   = initiative.Approbateur,
                        Cofinancement = initiative.Cofinancement,
                        Regions       = initiative.Regions,
                    };
                    db.Initiatives.Add(init);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }catch (Exception DbExc)
                {
                    TempData["Message"]   = DbExc;
                    ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
                    return(View(initiative));
                }
            }

            ViewBag.UtilisateurID = new SelectList(db.Utilisateur, "ID", "UserId", initiative.UtilisateurID);
            return(View(initiative));
        }
コード例 #12
0
ファイル: TurnManager.cs プロジェクト: cvance5/syphermia
 public static void RemoveCharacter(CharacterData removedCharacter)
 {
     Initiatives.Remove(removedCharacter);
 }