Пример #1
0
 public async Task <IActionResult> CreateImageCms(ImageCms imageCms)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (imageCms.Id == 0)
             {
                 await _imageCmsService.Create(imageCms);
             }
             else
             {
                 await _imageCmsService.Update(imageCms);
             }
             return(RedirectToAction("CreateImageCms", new
             {
                 id = imageCms.Id
             }));
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
     return(View(imageCms));
 }
Пример #2
0
        public async Task <IActionResult> CreateImageCms(short id = 0)
        {
            var imageCms = new ImageCms();

            if (id != 0)
            {
                imageCms = await _imageCmsService.GetAll().AsNoTracking().Include(f => f.File).FirstOrDefaultAsync(a => a.Id == id);
            }
            return(View(imageCms));
        }