// PLAN public void CreateIncomePlan(IncomePlanModel ip) { db.INCOME_PLAN.Add(new INCOME_PLAN() { plan_income_user_FK = ip.plan_income_user_FK, plan_income_type_Fk = ip.plan_income_type_Fk, plan_income_date = ip.plan_income_date, plan_income_size = ip.plan_income_size }); Save(); }
public void UpdateIncomePlan(IncomePlanModel ipm) { var u = db.USER.ToList().Where(i => i.id == ipm.plan_income_user_FK).FirstOrDefault(); INCOME_PLAN i_p = u.INCOME_PLAN.ToList().Where(i => ((DateTime)i.plan_income_date.Date) == ipm.plan_income_date.Date).FirstOrDefault(); if (i_p == null) { CreateIncomePlan(ipm); } else { i_p.plan_income_user_FK = ipm.plan_income_user_FK; i_p.plan_income_type_Fk = ipm.plan_income_type_Fk; i_p.plan_income_date = ipm.plan_income_date; i_p.plan_income_size = ipm.plan_income_size; Save(); } }