Exemplo n.º 1
0
        public IActionResult Get_Edit_Unit([FromQuery] UnitParam model) // done
        {
            UnitEditViewModel modelView = new UnitEditViewModel();

            modelView = repository_unit.Get_Edit_Unit(model);
            return(Json(modelView));
        }
        public IActionResult Edit(UnitEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Units unit = unitRepository.GetUnits(model.Id);
                unit.Name       = model.Name;
                unit.Attack     = model.Attack;
                unit.Defense    = model.Defense;
                unit.min_Damage = model.min_Damage;
                unit.max_Damage = model.max_Damage;
                unit.Health     = model.Health;
                unit.Faction    = model.Faction;

                if (model.Photo != null)
                {
                    if (model.ExistingPhotoPath != null)
                    {
                        string filePath = Path.Combine("wwwroot/images", model.ExistingPhotoPath);
                        System.IO.File.Delete(filePath);
                    }
                    unit.PhotoPath = ProcessUpload(model);
                }

                unitRepository.Update(unit);
                return(RedirectToAction("list"));
            }

            return(View());
        }
Exemplo n.º 3
0
        private void Edit(int unitId)
        {
            var model     = Units.Single(x => x.UnitId == unitId);
            var view      = new UnitEditView();
            var viewmodel = new UnitEditViewModel(model);

            view.DataContext = viewmodel;
            view.Show();
        }
Exemplo n.º 4
0
        public UnitEditViewModel Get_Edit_Unit(UnitParam model)
        {
            IQueryable <UnitEditViewModel> result = from a in context.Unit
                                                    where a.IdUnit == model.IdUnit
                                                    select new UnitEditViewModel
            {
                Name = a.NameUnit
            };
            UnitEditViewModel data = result.SingleOrDefault();

            return(data);
        }
        [Authorize]     //tylko uzytkownik zalogowany bedzie mial uprawnienia
        public ViewResult Edit(int id)
        {
            Units             unit = unitRepository.GetUnits(id);
            UnitEditViewModel unitEditViewModel = new UnitEditViewModel
            {
                Name              = unit.Name,
                Attack            = unit.Attack,
                Defense           = unit.Defense,
                min_Damage        = unit.min_Damage,
                max_Damage        = unit.max_Damage,
                Health            = unit.Health,
                Faction           = unit.Faction,
                ExistingPhotoPath = unit.PhotoPath
            };

            return(View(unitEditViewModel));
        }