public bool Insert(Pages_Metadata pages_Metadata, Int64 pageId)
        {
            Int64 applicationId = 0;

            try
            {
                if (pages_Metadata == null)
                {
                    return(false);
                }
                var Obj = _db.objPagesMetadata.Add(pages_Metadata);
                _db.SaveChanges();
                Application_Pages application_Pages = _db.ObjPages.Where(x => x.id == pageId).SingleOrDefault();
                if (application_Pages.applicationID > 0)
                {
                    applicationId            = application_Pages.applicationID;
                    application_Pages.metaId = pages_Metadata.id;
                    _db.ObjPages.Update(application_Pages);
                    _db.SaveChangesAsync();
                }
                return(true);
            }
            catch (Exception e)
            {
                LogError(e, applicationId, pageId);
                return(false);
            }
        }
 public Pages_Metadata Update(Pages_Metadata pages_Metadata)
 {
     try
     {
         if (pages_Metadata == null)
         {
             return(null);
         }
         _db.objPagesMetadata.Update(pages_Metadata);
         _db.SaveChangesAsync();
         return(pages_Metadata);
     }
     catch (Exception e)
     {
         var applicationPages = _db.ObjPages.Where(x => x.metaId == pages_Metadata.id);
         if (applicationPages == null)
         {
             LogError(e, applicationPages.First().applicationID, applicationPages.First().id);
         }
         else
         {
             LogError(e, 0, 0);
         }
         return(null);
     }
 }
 public IActionResult Insert([FromBodyAttribute] Pages_Metadata pages_Metadata, Int64 pageId)
 {
     if (_pages_MetadataRepository.Insert(pages_Metadata, pageId))
     {
         return(Ok(new Application_ResponseWrapper()
         {
             ResponseCode = "0", ResponseMessage = "Information saved", Status = "success", ResponseResult = pages_Metadata
         }));
     }
     return(Ok(new Application_ResponseWrapper()
     {
         ResponseCode = "1001", ResponseMessage = "Information not saved", Status = "failed"
     }));
 }
        public IActionResult FindById(long id, long pageId)
        {
            Pages_Metadata pages_Metadata = _pages_MetadataRepository.FindById(id);

            if (pages_Metadata == null)
            {
                return(Ok(new Application_ResponseWrapper()
                {
                    ResponseCode = "1001", ResponseMessage = "Result not found", Status = "failed"
                }));
            }
            return(Ok(new Application_ResponseWrapper()
            {
                ResponseCode = "0", ResponseMessage = "success", Status = "success", ResponseResult = pages_Metadata
            }));
        }
        public IActionResult Update([FromBodyAttribute] Pages_Metadata _pages_Metadata)
        {
            if (!ModelState.IsValid)
            {
                return(Ok(new Application_ResponseWrapper()
                {
                    ResponseCode = "1000", ResponseMessage = "invalid model", Status = "failed"
                }));
            }
            Pages_Metadata pages_Metadata = _pages_MetadataRepository.Update(_pages_Metadata);

            return(Ok(new Application_ResponseWrapper()
            {
                ResponseCode = "0", ResponseMessage = "Information saved", Status = "success", ResponseResult = pages_Metadata
            }));
        }