public async Task <IActionResult> EditDocumentAsync(DocSysDocument entity, IFormFile file)
        {
            ViewBag.departments = new SelectList(_departmentService.GetAll().Where(i => i.DepartmentIsDeleted == false && i.DepartmentIsActive).ToList(), "DepartmentId", "DepartmentName");
            var documentation = _documentService.GetById(entity.DocumentId);

            if (User.IsInRole("user"))
            {
                entity.DocumentIsApproved     = documentation.DocumentIsApproved;
                entity.DocumentOpentoEveryone = documentation.DocumentOpentoEveryone;
            }
            if (documentation != null)
            {
                if (file != null && file.ContentType.Contains("image"))
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\documents", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                    entity.DocumentImage = file.FileName;
                }
                else
                {
                    entity.DocumentImage = documentation.DocumentImage;
                }

                if (ModelState.IsValid)
                {
                    entity.DocumentCreatedDate = documentation.DocumentCreatedDate;
                    entity.DocumentUpdatedTime = DateTime.Now;
                    _documentService.Update(entity);
                    TempData.Put("message", new ResultMessage()
                    {
                        Title   = "Bildirim",
                        Message = "Dökümantasyon başarıyla güncellendi.",
                        Css     = "success"
                    });
                    return(RedirectToAction("Index"));
                }
            }

            TempData.Put("message", new ResultMessage()
            {
                Title   = "Bildirim",
                Message = "Dökümantasyon güncellenemedi. ",
                Css     = "danger"
            });
            return(View(entity));
        }
        public async Task <IActionResult> CreateDocumentAsync(DocSysDocument entity, IFormFile file)
        {
            if (User.IsInRole("user"))
            {
                entity.DocumentOpentoEveryone = false;
                entity.DocumentIsApproved     = false;
            }

            if (file != null && file.ContentType.Contains("image"))
            {
                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\documents", file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await file.CopyToAsync(stream);
                }
                entity.DocumentImage = file.FileName;
            }

            if (ModelState.IsValid)
            {
                entity.DocumentCreatedDate = DateTime.Now;
                entity.DocumentUpdatedTime = DateTime.Now;
                _documentService.Create(entity);
                TempData.Put("message", new ResultMessage()
                {
                    Title   = "Bildirim",
                    Message = "Dökümantasyon başarıyla oluşturuldu. Yetkili onayından sonra yayınlanabilir.",
                    Css     = "success"
                });
                return(RedirectToAction("UserDocument"));
            }
            TempData.Put("message", new ResultMessage()
            {
                Title   = "Bildirim",
                Message = "Dökümantasyon oluşturulamadı. ",
                Css     = "danger"
            });
            return(View(entity));
        }
 public void Update(DocSysDocument entity)
 {
     _docSysDocumentDAL.Update(entity);
 }
 public void Delete(DocSysDocument entity)
 {
     _docSysDocumentDAL.Delete(entity);
 }
 public void Create(DocSysDocument entity)
 {
     _docSysDocumentDAL.Create(entity);
 }