Esempio n. 1
0
 public async Task <Voyimage> ToVoyImageAsync(VoyImageViewModel model, string path, bool IsNew)
 {
     return(new Voyimage
     {
         Id = IsNew ? 0 : model.Id,
         Title = model.Title,
         ImageUrl = path,
         Voy = await _dataContext.Voys.FindAsync(model.Voy_id),
     });
 }
Esempio n. 2
0
        public async Task <IActionResult> AddVoyImage(int?id)
        {
            var voy = await _datacontext.Voys.FindAsync(id);

            if (id == null || voy == null)
            {
                return(NotFound());
            }

            var model = new VoyImageViewModel
            {
                Voy_id = voy.Id,
            };

            return(View(model));
        }
Esempio n. 3
0
        public async Task <IActionResult> EditVoyImage(VoyImageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = string.Empty;

                if (model.ImageFile != null)
                {
                    path = await _imageHelper.UpLoadImageAsync(model.ImageFile);
                }

                var voyimg = await _converterHelper.ToVoyImageAsync(model, path, false);

                _datacontext.Voyimages.Update(voyimg);
                await _datacontext.SaveChangesAsync();

                return(RedirectToAction($"VoyImagetList/{model.Voy_id}"));
            }

            return(View(model));
        }