Ejemplo n.º 1
0
        public async Task <IActionResult> EditTypesOfPrinting(TypeEditViewModel typeView)
        {
            if (typeView.TypeImage != null)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await typeView.TypeImage.CopyToAsync(memoryStream);

                    typeView.Type.Image         = memoryStream.ToArray();
                    typeView.Type.ImageMimeType = typeView.TypeImage.ContentType;
                }
            }
            if (ModelState.IsValid)
            {
                var category = new TypesOfPrinting
                {
                    Title       = typeView.Type.Title,
                    Description = typeView.Type.Description,
                    Image       = typeView.Type.Image
                };

                typeRepository.SaveType(typeView.Type);
                TempData["message"] = $"{typeView.Type.Title} has been saved";
                return(RedirectToAction("InformationList"));
            }
            else
            {
                // there is something wrong with the data values
                return(View(typeView));
            }
        }
Ejemplo n.º 2
0
        public IActionResult DeleteType(int typeId)
        {
            TypesOfPrinting deletedType = typeRepository.DeleteType(typeId);

            if (deletedType != null)
            {
                TempData["message"] = $"{deletedType.Title} was deleted";
            }
            return(RedirectToAction("InformationList"));
        }
Ejemplo n.º 3
0
        public FileContentResult GetImageType(TypesOfPrinting item)
        {
            TypesOfPrinting type = typeRepository.Types
                                   .FirstOrDefault(g => g.Id == item.Id);

            if (type != null)
            {
                return(File(type.Image, type.ImageMimeType));
            }
            else
            {
                return(null);
            }
        }