Ejemplo n.º 1
0
        public async Task <IActionResult> DocumentCategoryBrand([FromForm] DocumentTypeViewModel model)
        {
            string attachPath = string.Empty;

            if (model.formFile != null)
            {
                string fileName;
                string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile);

                if (message == "success")
                {
                    attachPath = fileName;
                }
            }
            DocumentCategoryBrand documentCategory = new DocumentCategoryBrand
            {
                Id             = (int)model.documentcategoryId,
                documentTypeId = model.documentTypeId,
                brandName      = model.documentCategoryName,
                brandNameBn    = model.documentCategoryNameBn,
                imagePath      = attachPath,
                shortOrder     = model.shortOrder
            };
            await lostAndFoundType.SaveDocumentCategoryBrand(documentCategory);

            return(RedirectToAction("DocumentCategoryBrand", new RouteValueDictionary(
                                        new { controller = "MasterInformation", action = "DocumentCategoryBrand", Id = model.documentTypeId })));
            // return RedirectToAction(nameof(DocumentCategoryBrand));
        }
        public async Task <int> SaveDocumentCategoryBrand(DocumentCategoryBrand documentCategoryBrand)
        {
            if (documentCategoryBrand.Id != 0)
            {
                _context.DocumentCategoryBrands.Update(documentCategoryBrand);
                await _context.SaveChangesAsync();

                return(1);
            }
            else
            {
                await _context.DocumentCategoryBrands.AddAsync(documentCategoryBrand);

                await _context.SaveChangesAsync();

                return(1);
            }
        }