Ejemplo n.º 1
0
 public async Task <AlertImage> ToAlertImageAsync(AlertImageViewModel model, string path, bool IsNew)
 {
     return(new AlertImage
     {
         Id = IsNew ? 0 : model.Id,
         Title = model.Title,
         ImageUrl = path,
         Alert = await _dataContext.Alerts.FindAsync(model.Alert_id)
     });
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddAlertImage(int?id)
        {
            var alert = await _datacontext.Alerts.FindAsync(id);

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

            var model = new AlertImageViewModel
            {
                Alert_id = alert.Id,
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> EditAlertImage(AlertImageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = string.Empty;

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

                var status = await _converterHelper.ToAlertImageAsync(model, path, false);

                _datacontext.AlertImages.Update(status);
                await _datacontext.SaveChangesAsync();

                return(RedirectToAction($"AlertImagetList/{model.Alert_id}"));
            }

            return(View(model));
        }