Пример #1
0
 public EditRace(RaceEditModel model)
 {
     BindingContext   = Model = model;
     Model.Navigation = Navigation;
     InitializeComponent();
     Model.TrackChanges = true;
 }
Пример #2
0
        public Response <bool> UpdateRace(RaceEditModel updateModel)
        {
            var transaction   = _raceContext.StartTransaction();
            var id            = updateModel.Id ?? Guid.NewGuid();
            var currentEntity = updateModel.Id == null
                ? new Race {
                Id = id
            }
                : _raceContext.GetById((Guid)updateModel.Id);

            currentEntity.Name        = updateModel.Name;
            currentEntity.Description = updateModel.Description ?? "";
            _raceContext.Upsert(currentEntity);

            updateModel.Attributes.SaveAttributes(id, _raceAttributeContext);

            transaction.Commit();
            return(new Response <bool>(true));
        }
Пример #3
0
        public int Save(RaceEditModel model)
        {
            var id = MappingSave(_raceRepository, model);

            var bonuses = model.Bonuses?.Select(x => new RaceBonus
            {
                RaceId  = model.Id,
                BonusId = x
            }).AsQueryable();

            _bonusService.BatchSave(bonuses, id, BonusType.Race);

            var abilities = model.Abilities?.Select(x => new RaceAbility()
            {
                RaceId    = model.Id,
                AbilityId = x.Id,
                Value     = x.Value
            }).AsQueryable();

            _abilityService.BatchSave(abilities, id);

            return(id);
        }