public bool UpdateDeathLine(DateTime ym, DateTime deathLine, int modifyUserId, out string error) { try { error = string.Empty; DeathLine updateDeathLine = GetDeathLineByKeyValues(ym); if (updateDeathLine != null) { updateDeathLine.DeathLineDate = deathLine; updateDeathLine.ModifyUserId = modifyUserId; updateDeathLine.ModifyDate = DateTime.Now; _ctx.SaveChanges(); return(true); } else { error = "No DeathLine data in database"; return(false); } } catch (Exception ex) { error = ex.Message; return(false); } }
public bool DeleteDeathLine(DateTime ym, out string error) { try { error = string.Empty; DeathLine removeDeathLine = GetDeathLineByKeyValues(ym); _ctx.DeathLines.Remove(removeDeathLine); _ctx.SaveChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
public DeathLineListModel(DeathLine deathLine, string nameOfUser) { if (deathLine != null) { YM = deathLine.YM; if (deathLine.DeathLineDate.HasValue) { DeathLineDate = deathLine.DeathLineDate.Value; } if (deathLine.ModifyDate.HasValue) { ModifyDate = deathLine.ModifyDate.Value; } if (deathLine.ModifyUserId.HasValue) { ModifyName = nameOfUser; } } }
public bool InsertDeathLine(DateTime ym, DateTime deathLine, int modifyUserId, out string error) { try { error = string.Empty; DeathLine newDeathLine = new DeathLine(); newDeathLine.YM = ym; newDeathLine.DeathLineDate = deathLine; newDeathLine.ModifyUserId = modifyUserId; newDeathLine.ModifyDate = DateTime.Now; _ctx.DeathLines.Add(newDeathLine); _ctx.SaveChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }