Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,UnitId")] Item item, IList <IFormFile> files)
        {
            if (ModelState.IsValid)
            {
                ServicesCommonFunctions.AddImage(ref item, files);
                await _itemService.AddAsync(item);

                return(RedirectToAction(nameof(Index)));
            }
            SetViewData();
            return(View(item));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UploadImage(long?id, IList <IFormFile> files)
        {
            var item = await _itemService.GetAsync(id);

            if (item == null)
            {
                return(NotFound());
            }
            ServicesCommonFunctions.AddImage(ref item, files);
            await _itemService.UpdateAsync(item);

            return(RedirectToAction(nameof(Edit), new { id = item.Id }));
        }