public JsonResult UpdateRequest(OfficeDocDetailsViewModel obj)
        {
            try
            {
                DateTime?expiry = null;
                if (obj.DocExpiryDate == DateTime.MinValue)
                {
                    expiry = null;
                }
                else
                {
                    expiry = obj.DocExpiryDate;
                }
                var fetchedDocs = objUnitOfWorkFetch.OfficeDocDetailsRepository.Get(x => x.OfficeDocId == obj.OfficeDocId).ToList();
                var officeDoc   = new OfficeDocDetails()
                {
                    OfficeDocId   = obj.OfficeDocId,
                    DocumentId    = obj.DocumentId,
                    OfficeDocDesc = obj.OfficeDocDesc,
                    DocIssueDate  = obj.DocIssueDate,
                    DocExpiryDate = expiry,
                    IsActive      = obj.IsActive,
                    CreatedBy     = fetchedDocs[0].CreatedBy,
                    CreatedDate   = fetchedDocs[0].CreatedDate,
                    ModifiedBy    = Convert.ToInt32(TempData.Peek("UserId")),
                    ModifiedDate  = DateTime.Now
                };

                UnitOfWork.OfficeDocDetailsRepository.Update(officeDoc);
                UnitOfWork.Save();

                var uploadedData = UnitOfWork.OfficeDocsFileUploadsRepository.Get(f => f.IsValid == 0 && f.DocumentId == obj.DocumentId);
                foreach (var item in uploadedData)
                {
                    item.IsValid      = 1;
                    item.ModifiedBy   = Convert.ToInt32(TempData.Peek("UserId"));
                    item.ModifiedDate = DateTime.Now;
                    UnitOfWork.OfficeDocsFileUploadsRepository.Update(item);
                    UnitOfWork.Save();
                }
                return(Json(new { success = true, responseText = "Document Updated successfully." }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                return(Json(new { success = false, responseText = "Something went wrong." }));
            }
        }
 public JsonResult IsDocumentExists(OfficeDocDetails obj)
 {
     try
     {
         var  docs = UnitOfWork.OfficeDocDetailsRepository.Get();
         bool has  = docs.ToList().Any(x => x.DocumentId == obj.DocumentId);
         if (has)
         {
             return(Json(new { value = true, responseText = "Document name exists" }));
         }
         else
         {
             return(Json(new { value = false, responseText = "Document name is not exists" }));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.ToString());
         return(Json(new { value = true, responseText = "Document name exists" }));
     }
 }
 public JsonResult GetIsExpiryEnabled(OfficeDocDetails obj)
 {
     try
     {
         var  docs = UnitOfWork.DocumentTypeRepository.Get(d => d.DocumentId == obj.DocumentId);
         bool has  = docs.ToList().Any(x => x.IsExpiryRequired == 1);
         if (has)
         {
             return(Json(new { value = true }));
         }
         else
         {
             return(Json(new { value = false }));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.ToString());
         return(Json(new { value = false }));
     }
 }