Пример #1
0
        public virtual async Task <ActionResult> Create(CityModel viewModel)
        {
            ViewBag.Country = CList();
            if (ModelState.IsValid)
            {
                if (!_City.IsExist(viewModel.Name))
                {
                    var item = new CityModel
                    {
                        Name      = viewModel.Name,
                        CountryID = viewModel.CountryID
                    };
                    _City.Add(item);
                    await _uow.SaveChangesAsync();

                    return(View());
                }
                else
                {
                    ViewBag.Message = "عنوان وارد شده تکراری است.";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Пример #2
0
        public void AddStructure(ushort type, byte lvl)
        {
            IStructure structure = Ioc.Kernel.Get <StructureCsvFactory>().GetNewStructure(type, lvl);

            city.Add(structure);
            structures.Add(structure);
        }
Пример #3
0
        public async Task <IActionResult> Add([FromBody] City city)
        {
            try
            {
                if (city == null)
                {
                    return(BadRequest());
                }

                await _city.Add(city);

                return(Ok(city));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }
Пример #4
0
        public IHttpActionResult Add(TOURIS_TV_CITY cityView)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_CITY city = new TOURIS_TM_CITY();
                city.PROVINCE_ID      = cityView.PROVINCE_ID;
                city.CITY_CODE        = cityView.CITY_CODE;
                city.CITY_NAME        = cityView.CITY_NAME;
                city.CITY_DESCRIPTION = cityView.CITY_DESCRIPTION;
                city.CREATED_BY       = cityView.CREATED_BY;
                city.CREATED_TIME     = cityView.CREATED_TIME;
                city.ROW_STATUS       = eStat.fg.IsActive;

                rs = repo.Add(city);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
Пример #5
0
        public async Task <ActionResult <City> > AddCity(CityViewModel model)
        {
            if (ModelState.IsValid)
            {
                City city = new City
                {
                    Code        = model.Code,
                    Description = model.Description,
                    CountryCode = model.CountryCode
                };
                var result = await repository.Add(city);

                return(StatusCode(StatusCodes.Status201Created, result));
            }
            else
            {
                //ModelState.AddModelError(StatusCodes.Status400BadRequest.ToString(), "Unable to save state record.")
                return(StatusCode(StatusCodes.Status400BadRequest, "Unable to save city record."));
            }
        }
Пример #6
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.City model)
 {
     return(dal.Add(model));
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Ncu.jsj.Model.City model)
 {
     return(dal.Add(model));
 }
Пример #8
0
        public Group()
        {
            player = new Player(playerId,
                                DateTime.MinValue,
                                SystemClock.Now,
                                "player " + playerId,
                                string.Empty,
                                PlayerRights.Basic);
            playerId++;
            BaseBattleStats baseBattleStats = new BaseBattleStats(type: 2000,
                                                                  lvl: 1,
                                                                  weapon: WeaponType.Sword,
                                                                  wpnClass: WeaponClass.Elemental,
                                                                  armor: ArmorType.Building3,
                                                                  armrClass: ArmorClass.Stone,
                                                                  maxHp: 500,
                                                                  atk: 0,
                                                                  splash: 0,
                                                                  range: 0,
                                                                  stealth: 0,
                                                                  speed: 0,
                                                                  groupSize: 1,
                                                                  carry: 0,
                                                                  normalizedCost: 0);
            StructureBaseStats structureBaseStats = new StructureBaseStats(name: "MainBuilding",
                                                                           spriteClass: "",
                                                                           type: 2000,
                                                                           lvl: 1,
                                                                           radius: 0,
                                                                           cost: null,
                                                                           baseBattleStats: baseBattleStats,
                                                                           maxLabor: 0,
                                                                           buildTime: 0,
                                                                           workerId: 0);
            StructureStats structurestats = new StructureStats(structureBaseStats);

            var main = new Structure(structurestats);

            city = Ioc.Kernel.Get <ICityFactory>()
                   .CreateCity(id: cityId,
                               owner: player,
                               name: "city " + cityId,
                               resource: Formula.Current.GetInitialCityResources(),
                               radius: Formula.Current.GetInitialCityRadius(),
                               ap: 0);

            main.ObjectId = 1;
            city.Add(main.ObjectId, main, false);
            player.Add(city);
            cityId++;

            AttackStub = new TroopStub(0, city);
            AttackStub.AddFormation(FormationType.Normal);
            obj = new TroopObject(AttackStub);
            using (Concurrency.Current.Lock(city))
            {
                city.Troops.Add(AttackStub);
                city.Add(obj);
            }

            TroopObject = new TroopObject(AttackStub)
            {
                X = city.X, Y = city.Y
            };
            TroopObject.BeginUpdate();
            TroopObject.Stats = new TroopStats(Formula.Current.GetTroopRadius(AttackStub, null),
                                               Formula.Current.GetTroopSpeed(AttackStub));
            TroopObject.EndUpdate();

            city.Add(TroopObject);
        }