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 bool Insert(Application_Pages ObjPages) { try { if (ObjPages == null) { return(false); } int maxIndex = 0; ObjPages.createdDate = DateTime.Now; if (_db.ObjPages.Where(p => p.index >= 0).ToList().Count > 0) { maxIndex = _db.ObjPages.Max(p => p.index) + 1; } ObjPages.index = maxIndex; var Obj = _db.ObjPages.Add(ObjPages); _db.SaveChanges(); return(true); } catch (Exception e) { LogError(e, ObjPages.applicationID, ObjPages.id); return(false); } }
public bool DeleteById(Int64 Id, Int64 PageId) { Int64 applicationId = 0; var obj = FindById(Id); try { if (obj == null) { return(false); } var Obj = _db.objPagesMetadata.Remove(obj); _db.SaveChanges(); //update the meta id in pages primary table by reseting with 0 Application_Pages application_Pages = _db.ObjPages.Where(x => x.id == PageId).SingleOrDefault(); if (application_Pages.applicationID > 0) { applicationId = application_Pages.applicationID; application_Pages.metaId = 0; _db.ObjPages.Update(application_Pages); _db.SaveChangesAsync(); } return(true); } catch (Exception e) { LogError(e, applicationId, PageId); return(false); } }
public IActionResult UpdateIndex(Int64 pageId, Int32 Index) { if (pageId == 0 || Index < 0) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "1000", ResponseMessage = "invalid model", Status = "failed" })); } Application_Pages pages = _pagesRepository.FindById(pageId); if (pages == null) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "1000", ResponseMessage = "invalid model", Status = "failed" })); } pages.index = Index; Application_Pages pageUpdated = _pagesRepository.Update(pages); return(Ok(new Application_ResponseWrapper() { ResponseCode = "0", ResponseMessage = "Information saved", Status = "success", ResponseResult = pages })); }
public IActionResult Insert([FromBodyAttribute] Application_Pages pages) { pages.guid = Guid.NewGuid().ToString(); if (_pagesRepository.Insert(pages)) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "0", ResponseMessage = "Information saved", Status = "success", ResponseResult = pages })); } return(Ok(new Application_ResponseWrapper() { ResponseCode = "1001", ResponseMessage = "Information not saved", Status = "failed" })); }
public IActionResult Update([FromBodyAttribute] Application_Pages _pages) { if (!ModelState.IsValid) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "1000", ResponseMessage = "invalid model", Status = "failed" })); } Application_Pages pages = _pagesRepository.Update(_pages); return(Ok(new Application_ResponseWrapper() { ResponseCode = "0", ResponseMessage = "Information saved", Status = "success", ResponseResult = pages })); }
public IActionResult FindById(long id) { Application_Pages pages = _pagesRepository.FindById(id); if (pages == 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 })); }
public Application_Pages Update(Application_Pages ObjPages) { try { if (ObjPages == null) { return(null); } ObjPages.modifiedDate = DateTime.Now; _db.ObjPages.Update(ObjPages); _db.SaveChanges(); return(ObjPages); } catch (Exception e) { LogError(e, ObjPages.applicationID, ObjPages.id); return(null); } }