Example #1
0
        public bool CheckIfPlayerOwnAllLandInLandGroup(Player player, LandGroup groupe)
        {
            int nbLandPlayer = player.ListOfProperties.Where(l => l.Status != Property.MORTGAGED).Where(l => l is Land).Cast <Land>().ToList().Where(land => land.LandGroup.IdGroup.Equals(groupe.IdGroup)).Count();

            int nbLandBoard = CountTheNumberOfLandInLandGroup(groupe);

            if (nbLandPlayer == nbLandBoard)
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        [Authorize(Roles = "QL,LandGroup,LandGroupD")] //Delete
        public int DeleteConfirmed(string[] inputCheck)
        {
            int rowFinish = 0;

            if (inputCheck == null)
            {
                return(rowFinish);
            }
            foreach (var s in inputCheck)
            {
                try
                {
                    int       idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s));
                    LandGroup obj    = db.LandGroups.Find(idMenu);
                    //1-them, 2- sua, 3-xoa, 4- khac
                    shared.CreateHistory(new History()
                    {
                        Name    = "Xóa LandGroup",
                        Contens = JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings()
                        {
                            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                        }),
                        ItemId = obj.LandGroupId,
                        Type   = (int)DefineFuntion.TypeHistory.LandGroup,
                    });
                    db.LandGroups.Remove(obj);
                    db.SaveChanges();
                    rowFinish++;
                }
                catch (Exception)
                {
                    int       idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s));
                    LandGroup obj    = db.LandGroups.Find(idMenu);
                    obj.Status = 3;
                    db.SaveChanges();
                }
            }
            return(rowFinish);
        }
Example #3
0
        public ActionResult Edit(LandGroup landGroup, string codeSystem, string typeName)
        {
            landGroup.LandGroupId = Convert.ToInt32(DefineFuntion.Decrypt(codeSystem));
            int ms = 0;
            var me = db.LandGroups.Find(landGroup.LandGroupId);

            try
            {
                me.Name   = landGroup.Name;
                me.Status = landGroup.Status;
                me.Note   = landGroup.Note;
                db.SaveChanges();
                ms = 3;//Nếu cập nhật thành công
                //1-them, 2- sua, 3-xoa, 4- khac
                shared.CreateHistory(new History()
                {
                    Name    = "Xóa Chức Vụ",
                    Contens = JsonConvert.SerializeObject(me, Formatting.Indented, new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                    }),
                    ItemId = me.LandGroupId,
                    Type   = (int)DefineFuntion.TypeHistory.LandGroup,
                });
            }
            catch (Exception)
            {
                ms = 4;//Nếu cập nhật không thành công
            }
            if (typeName == "savenew" || typeName == "")
            {
                return(RedirectToAction("Create", new { mess = ms }));
            }
            else
            {
                return(RedirectToAction("Edit", new { id = codeSystem, mess = ms }));
            }
        }
Example #4
0
        public ActionResult Create(LandGroup landGroup, string typeName)
        {
            var shared = new SharedFuntionController();
            int ms     = 0;

            try
            {
                db.LandGroups.Add(landGroup);
                db.SaveChanges();
                ms = 1;
                //1-them, 2- sua, 3-xoa, 4- khac
                shared.CreateHistory(new History()
                {
                    Name    = "Thêm LandGroup",
                    Contens = "",
                    ItemId  = landGroup.LandGroupId,
                    Type    = (int)DefineFuntion.TypeHistory.LandGroup,
                });
            }
            catch (Exception ex)
            {
                ms          = 2;
                ViewBag.Err = ex.InnerException;
            }
            if (ms != 2)
            {
                if (typeName == "savenew" || typeName == "")
                {
                    return(RedirectToAction("Create", new { mess = ms }));
                }
                else
                {
                    return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(landGroup.LandGroupId), mess = ms }));
                }
            }
            ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", landGroup.Status);
            return(View());
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="groupe"></param>
 private int CountTheNumberOfLandInLandGroup(LandGroup groupe)
 {
     return(BoardHandler.Instance.Board.ListCell.Where(l => l is Land).Cast <Land>().ToList().Where(land => land.LandGroup.IdGroup.Equals(groupe.IdGroup)).Count());
 }