public ActionResult UpdateActiveStatus(int entryid, bool isactive) { IDbConnection db = new OrmliteConnection().openConn(); try { var isExist = BillDetail.GetById(entryid, null, false); isExist.isactive = isactive; isExist.updatedby = currentUser.entryid; isExist.updatedat = DateTime.Now; db.UpdateOnly(isExist, onlyFields: p => new { p.isactive, p.updatedat, p.updatedby }, where : p => p.entryid == entryid); return(Json(new { success = true })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }
public ActionResult GetByID(int entryid) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = BillDetail.GetById(entryid, null, false); var ref_Roles = CustomModel.GetActiveStatus(); return(Json(new { success = true, data = data })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public ActionResult Create(BillDetail item) { IDbConnection db = new OrmliteConnection().openConn(); try { item.entryname = item.entryname ?? ""; item.entrycode = item.entrycode ?? ""; //if (string.IsNullOrEmpty(item.entryname) || string.IsNullOrEmpty(item.entrycode)) return Json(new { success = false, message = tw_Lang.Common_ActionResult_MissingInfo }); var isExist = BillDetail.GetById(item.entryid, null, false); //Validate //insert / update if (item.entryid == 0) { //insert item.createdat = DateTime.Now; item.createdby = currentUser.entryid; item.updatedat = DateTime.Now; item.updatedby = currentUser.entryid; item.isactive = true; } else { //update item.createdby = isExist.createdby; item.updatedat = DateTime.Now; item.updatedby = currentUser.entryid; } item.AddOrUpdate(currentUser.entryid, null, false); return(Json(new { success = true, data = item })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }