/// <summary> /// Gets Card Allows. /// </summary> /// <param name="db">The database connection.</param> /// <returns>Returns List of Card Allow Master.</returns> public static NDbResult <List <MCardAllow> > GetCardAllows(SQLiteConnection db) { var result = new NDbResult <List <MCardAllow> >(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * FROM MCardAllow "; result.Success(); var data = NQuery.Query <MCardAllow>(cmd); result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets by UserId and password. /// </summary> /// <param name="userId">The UserId.</param> /// /// <param name="password">The password in MD5.</param> /// <returns>Returns User instance.</returns> public static NDbResult <User> GetByUserId(string userId, string password) { var result = new NDbResult <User>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserView "; cmd += " WHERE UserId = ? "; cmd += " AND Password = ? "; var ret = NQuery.Query <FKs>(cmd, userId, password).FirstOrDefault(); var data = (null != ret) ? ret.ToModel() : null; result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Users. /// </summary> /// <param name="db">The database connection.</param> /// <returns>Returns List of User.</returns> public static NDbResult <List <User> > GetUsers(SQLiteConnection db) { var result = new NDbResult <List <User> >(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserView "; var rets = NQuery.Query <FKs>(cmd).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Un Close User Shifts. /// </summary> /// <param name="tsbid">The TSB Id.</param> /// <returns>Returns List of User Shifts.</returns> public static NDbResult <List <UserShift> > GetUnCloseUserShifts(string tsbid) { var result = new NDbResult <List <UserShift> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserShiftView "; cmd += " WHERE TSBId = ? "; cmd += " AND End = ? "; var rets = NQuery.Query <FKs>(cmd, tsbid, DateTime.MinValue).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Create Lane Attendance. /// </summary> /// <param name="lane">The Lane instance.</param> /// <param name="collector">The User instance.</param> /// <returns>Returns LaneAttendance instance.</returns> public static NDbResult <LaneAttendance> Create(Lane lane, User collector) { var result = new NDbResult <LaneAttendance>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } LaneAttendance inst = Create(); var tsb = TSB.GetCurrent().Value(); if (null == tsb) { result.ParameterIsNull(); } else { if (null != tsb) { tsb.AssignTo(inst); } if (null != lane) { lane.AssignTo(inst); } if (null != collector) { collector.AssignTo(inst); } result.Success(inst); } return(result); }
/// <summary> /// Gets Plaza Lane. /// </summary> /// <param name="plazaId">The plaza Id.</param> /// <param name="laneNo">The lane number.</param> /// <returns>Returns match lane.</returns> public static NDbResult <Lane> GetPlazaLane(string plazaId, int laneNo) { var result = new NDbResult <Lane>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM LaneView "; cmd += " WHERE PlazaId = ? "; cmd += " AND LaneNo = ? "; var ret = NQuery.Query <FKs>(cmd, plazaId, laneNo).FirstOrDefault(); var data = (null != ret) ? ret.ToModel() : null; result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
public static NDbResult SaveMCardAllows(List <MCardAllow> values) { lock (sync) { SQLiteConnection db = Default; MethodBase med = MethodBase.GetCurrentMethod(); var result = new NDbResult(); try { db.BeginTransaction(); values.ForEach(value => { MCardAllow.Save(value); }); db.Commit(); result.Success(); } catch (Exception ex) { db.Rollback(); med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets All TSB Coupon Balance. /// </summary> /// <returns>Returns List fo all TSB Coupon balance.</returns> public static NDbResult <List <TSBCouponBalance> > GetTSBBalances() { var result = new NDbResult <List <TSBCouponBalance> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = @" SELECT * FROM TSBCouponBalanceView " ; var rets = NQuery.Query <FKs>(cmd).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Shift. /// </summary> /// <param name="db">The database connection.</param> /// <param name="shiftId">The Shift Id.</param> /// <returns>Returns Shift instance.</returns> public static NDbResult <Shift> GetShift(SQLiteConnection db, string shiftId) { var result = new NDbResult <Shift>(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * FROM Shift "; cmd += " WHERE ShiftId = ? "; var data = NQuery.Query <Shift>(cmd, shiftId).FirstOrDefault(); result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Role. /// </summary> /// <param name="db">The database connection.</param> /// <param name="roleId">The Role Id.</param> /// <returns>Returns Role instance.</returns> public static NDbResult <Role> GetRole(SQLiteConnection db, string roleId) { var result = new NDbResult <Role>(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * FROM Role "; cmd += " WHERE RoleId = ? "; var results = NQuery.Query <Role>(cmd, roleId).FirstOrDefault(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Find Users by Group Id. /// </summary> /// <param name="groupId">The Group Id.</param> /// <param name="status">The status.</param> /// <returns>Returns List of User.</returns> public static NDbResult <List <User> > FindByGroupId(int groupId, int status) { var result = new NDbResult <List <User> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserView "; cmd += " WHERE GroupId = ? "; cmd += " AND Status = ? "; var rets = NQuery.Query <FKs>(cmd, groupId, status).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets UserShift by TSBId and UserId. /// </summary> /// <param name="tsbId">Ths TSB id.</param> /// <param name="userId">The User Id.</param> /// <returns>Returns UserShift instance.</returns> public static NDbResult <UserShift> GetUserShift(string tsbId, string userId) { var result = new NDbResult <UserShift>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserShiftView "; cmd += " WHERE TSBId = ? "; cmd += " AND UserId = ? "; cmd += " AND End = ? "; var ret = NQuery.Query <FKs>(cmd, tsbId, userId, DateTime.MinValue).FirstOrDefault(); result.data = (null != ret) ? ret.ToModel() : null; result.Success(); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Plazas (By PlazaGroup Id). /// </summary> /// <param name="tsbId">The TSB Id.</param> /// <param name="plazaGroupId">The PlazaGroup Id.</param> /// <returns>Returns List of Plaza.</returns> public static NDbResult <List <Plaza> > GetPlazaGroupPlazas( string tsbId, string plazaGroupId) { var result = new NDbResult <List <Plaza> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM PlazaView "; cmd += " WHERE TSBId = ? "; cmd += " AND PlazaGroupId = ? "; var rets = NQuery.Query <FKs>(cmd, tsbId, plazaGroupId).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Create UserShift. /// </summary> /// <param name="shift">The Shift instance.</param> /// <param name="supervisor">The User instance.</param> /// <returns>Returns UserShift instance.</returns> public static NDbResult <UserShift> Create(Shift shift, User supervisor) { var result = new NDbResult <UserShift>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } UserShift inst = Create(); var tsb = TSB.GetCurrent().Value(); if (null != tsb) { tsb.AssignTo(inst); } if (null != shift) { shift.AssignTo(inst); } if (null != supervisor) { supervisor.AssignTo(inst); } result.Success(inst); return(result); }
/// <summary> /// Gets PlazaGroups (By TSBId). /// </summary> /// <param name="tsbId">The TSB Id.</param> /// <returns>Returns List of PlazaGroup.</returns> public static NDbResult <List <PlazaGroup> > GetTSBPlazaGroups(string tsbId) { var result = new NDbResult <List <PlazaGroup> >(); lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM PlazaGroupView "; cmd += " WHERE TSBId = ? "; var rets = NQuery.Query <FKs>(cmd, tsbId).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Active TSB. /// </summary> /// <returns>Returns Active TSB instance.</returns> public static NDbResult <TSB> GetCurrent() { var result = new NDbResult <TSB>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { // inactive all TSBs string cmd = string.Empty; cmd += "SELECT * FROM TSB "; cmd += " WHERE Active = 1 "; var results = NQuery.Query <TSB>(cmd); var data = (null != results) ? results.FirstOrDefault() : null; result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Plaza by SCW Id. /// </summary> /// <param name="db">The database connection.</param> /// <param name="scwPlazaId">The SCW Plaza Id</param> /// <returns>Returns Plaza instance.</returns> public static NDbResult <Plaza> GetPlazaBySCWPlazaId(SQLiteConnection db, int scwPlazaId) { var result = new NDbResult <Plaza>(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM PlazaView "; cmd += " WHERE SCWPlazaId = ? "; var ret = NQuery.Query <FKs>(cmd, scwPlazaId).FirstOrDefault(); var data = (null != ret) ? ret.ToModel() : null; result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets TSB Coupon summaries. /// </summary> /// <param name="tsb">The target TSB to get balance.</param> /// <returns>Returns List of TSB Coupon balance. If TSB not found returns null.</returns> public static NDbResult <List <TSBCouponSummary> > GetTSBCouponSummaries(TSB tsb) { var result = new NDbResult <List <TSBCouponSummary> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == tsb) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = @" SELECT * FROM TSBCouponSummarryView WHERE TSBId = ? " ; var rets = NQuery.Query <FKs>(cmd, tsb.TSBId).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets List of BHT35 by User in target TSB. /// </summary> /// <param name="tsb">The target TSB instance.</param> /// <param name="user">The user instance.</param> /// <returns>Returns List of BHT35.</returns> public static NDbResult <List <UserCouponTransaction> > GetUserBHT35Coupons( TSB tsb, User user) { var result = new NDbResult <List <UserCouponTransaction> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == tsb) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserCouponTransactionView "; cmd += " WHERE TSBId = ? "; cmd += " AND CouponType = ? "; if (null != user) { cmd += " AND UserId = ? "; } List <FKs> rets; if (null != user) { rets = NQuery.Query <FKs>(cmd, tsb.TSBId, CouponType.BHT35, user.UserId).ToList(); } else { rets = NQuery.Query <FKs>(cmd, tsb.TSBId, CouponType.BHT35).ToList(); } var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
public static NDbResult <List <TSBExchangeGroup> > GetTSBExchangeGroups(TSB tsb, StateTypes state, FinishedFlags flag, DateTime reqBegin, DateTime reqEnd) { var result = new NDbResult <List <TSBExchangeGroup> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == tsb) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM TSBExchangeGroupView "; cmd += " WHERE TSBId = ? "; cmd += " AND FinishFlag = ? "; if (state != StateTypes.None) { cmd += " AND State = ? "; } if (reqBegin != DateTime.MinValue) { cmd += " AND RequestDate >= ? "; if (reqEnd != DateTime.MinValue) { cmd += " AND RequestDate <= ? "; } } var rets = NQuery.Query <FKs>(cmd, tsb.TSBId, flag, state, reqBegin, reqEnd).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
public static NDbResult <List <LaneAttendance> > GetAllNotHasRevenueEntryByUser(User user) { var result = new NDbResult <List <LaneAttendance> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == user) { result.ParameterIsNull(); return(result); } var tsb = TSB.GetCurrent().Value(); if (null == tsb) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM LaneAttendanceView "; cmd += " WHERE TSBId = ? "; cmd += " AND (RevenueDate = ?"; cmd += " OR RevenueId IS NULL "; cmd += " OR RevenueId = ?) "; cmd += " AND UserId = ? "; cmd += " ORDER BY UserId, Begin"; var rets = NQuery.Query <FKs>(cmd, tsb.TSBId, DateTime.MinValue, string.Empty, user.UserId).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Begin User Shift. /// </summary> /// <param name="value">The UserShift instance.</param> /// <returns>Returns Begin User Shift Result.</returns> public static NDbResult BeginUserShift(UserShift value) { var result = new NDbResult(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == value) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { var last = GetUserShift(value.TSBId, value.UserId); if (null != last && null != last.data && !last.errors.hasError) { // not enter revenue entry. result.Error(new Exception("ยังมีกะที่ยังไม่ได้ป้อนรายได้")); result.errors.errNum = -10; return(result); } // Begin new shift. if (value.Begin == DateTime.MinValue) { value.Begin = DateTime.Now; } var saveRet = Save(value); result.errors = saveRet.errors; if (!result.errors.hasError) { result.Success(); } } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Change Shift. /// </summary> /// <param name="value">The TSBShift instance.</param> /// <returns>Returns Change Shift result.</returns> public static NDbResult ChangeShift(TSBShift value) { var result = new NDbResult(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == value) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { var last = GetTSBShift(value.TSBId).Value(); if (null != last) { // End shift. last.End = DateTime.Now; Save(last); } // Begin new shift. if (value.Begin == DateTime.MinValue) { value.Begin = DateTime.Now; } var saveRet = Save(value); result.errors = saveRet.errors; if (!result.errors.hasError) { result.Success(); } } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Search. /// </summary> /// <param name="shift">The User Shift instance.</param> /// <returns>Returns List of LaneAttendance.</returns> public static NDbResult <List <LaneAttendance> > Search(UserShift shift) { var result = new NDbResult <List <LaneAttendance> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == shift) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM LaneAttendanceView "; cmd += " WHERE UserId = ? "; cmd += " AND (Begin >= ? AND Begin <= ?) "; cmd += " AND ( (End >= ? AND End <= ?) " + " OR End = ?)"; cmd += " ORDER BY UserId, Begin"; DateTime end = (shift.End == DateTime.MinValue) ? DateTime.Now : shift.End; var rets = NQuery.Query <FKs>(cmd, shift.UserId, shift.Begin, end, shift.Begin, end, DateTime.MinValue).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Search By User Id (with SQL Like filter). /// </summary> /// <param name="db">The database connection.</param> /// <param name="userId">The User Id.</param> /// <param name="roles">The roles Id list.</param> /// <returns>Returns List of User.</returns> public static NDbResult <List <User> > SearchById(SQLiteConnection db, string userId, string[] roles) { var result = new NDbResult <List <User> >(); if (null == db) { result.DbConenctFailed(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM UserView "; cmd += " WHERE UserId like ? "; if (null != roles && roles.Length > 0) { cmd += " AND RoleId IN ( "; for (int i = 0; i < roles.Length; i++) { cmd += string.Format("'{0}'", roles[i]); if (i < roles.Length - 1) { cmd += ", "; } } cmd += " ) "; } var rets = NQuery.Query <FKs>(cmd, "%" + userId + "%").ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Create Lane Payment. /// </summary> /// <param name="lane">The Lane instance.</param> /// <param name="collector">The User instance.</param> /// <param name="payment">The Payment instance.</param> /// <param name="date">The payment date time.</param> /// <param name="amount">The payment amount.</param> /// <returns>Returns LanePayment instance.</returns> public static NDbResult <LanePayment> Create(Lane lane, User collector, Payment payment, DateTime date, decimal amount) { var result = new NDbResult <LanePayment>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } LanePayment inst = Create(); var tsb = TSB.GetCurrent().Value(); if (null == tsb) { result.ParameterIsNull(); } else { if (null != tsb) { tsb.AssignTo(inst); } if (null != lane) { lane.AssignTo(inst); } if (null != collector) { collector.AssignTo(inst); } if (null != payment) { payment.AssignTo(inst); } inst.PaymentDate = date; inst.Amount = amount; result.Success(inst); } return(result); }
public static NDbResult <List <TSBExchangeGroup> > GetRequestApproveTSBExchangeGroups(TSB tsb) { var result = new NDbResult <List <TSBExchangeGroup> >(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == tsb) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM TSBExchangeGroupView "; cmd += " WHERE TSBId = ? "; cmd += " AND (State = ? OR State = ?)"; cmd += " AND FinishFlag = ? "; var rets = NQuery.Query <FKs>(cmd, tsb.TSBId, StateTypes.Request, StateTypes.Approve, FinishedFlags.Avaliable).ToList(); var results = rets.ToModels(); result.Success(results); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Create Plaza Revenue. /// </summary> /// <param name="shift">The UserShift instance.</param> /// <param name="plazaGroup">The PlazaGroup instance.</param> /// <returns>Returns UserShiftRevenue instance.</returns> public static NDbResult <UserShiftRevenue> CreatePlazaRevenue( UserShift shift, PlazaGroup plazaGroup) { var result = new NDbResult <UserShiftRevenue>(); if (null == shift || null == plazaGroup) { result.ParameterIsNull(); result.data = null; } else { UserShiftRevenue inst = Create(); plazaGroup.AssignTo(inst); shift.AssignTo(inst); result.data = inst; result.Success(); } return(result); }
/// <summary> /// End User Shift. /// </summary> /// <param name="value">The UserShift instance.</param> /// <returns>Returns End User Shift Result.</returns> public static NDbResult EndUserShift(UserShift value) { var result = new NDbResult(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == value) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { // End shift. if (value.End == DateTime.MinValue) { value.End = DateTime.Now; } var saveRet = Save(value); result.errors = saveRet.errors; if (!result.errors.hasError) { result.Success(); } } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }
/// <summary> /// Gets Current Lane Attendance by Lane. /// </summary> /// <param name="lane">The Lane instance.</param> /// <returns>Returns LaneAttendance instance.</returns> public static NDbResult <LaneAttendance> GetCurrentByLane(Lane lane) { var result = new NDbResult <LaneAttendance>(); SQLiteConnection db = Default; if (null == db) { result.DbConenctFailed(); return(result); } if (null == lane) { result.ParameterIsNull(); return(result); } lock (sync) { MethodBase med = MethodBase.GetCurrentMethod(); try { string cmd = string.Empty; cmd += "SELECT * "; cmd += " FROM LaneAttendanceView "; cmd += " WHERE LaneId = ? "; cmd += " AND End = ? "; cmd += " ORDER BY UserId, Begin"; var ret = NQuery.Query <FKs>(cmd, lane.LaneId, DateTime.MinValue).FirstOrDefault(); var data = (null != ret) ? ret.ToModel() : null; result.Success(data); } catch (Exception ex) { med.Err(ex); result.Error(ex); } return(result); } }