public FundsValue Get(int id) { if (id != 0) { PersonalContext pc = new PersonalContext(); return((from c in pc.FundsValue where c.FvId == id select c).FirstOrDefault()); } else { FundsValue fv = new FundsValue(); fv.FundName = ""; //fv.Value = "Value"; fv.CyberAccountId = ""; // fv.Date = "Date"; return(fv); } }
public void Post([FromBody] FundsValue value) { PersonalContext pc = new PersonalContext(); var rec = (from c in pc.FundsValue where c.FundName == value.FundName && c.CyberAccountId == value.CyberAccountId && c.Date > DateTime.Now.AddDays(-10) select c).FirstOrDefault(); if (rec != null) { rec.Value = value.Value; rec.CyberAccountId = value.CyberAccountId; rec.Date = DateTime.Now; pc.Update(rec); } else { FundsValue fv = new FundsValue(); fv.FundName = value.FundName; fv.Value = value.Value; fv.CyberAccountId = value.CyberAccountId; fv.Date = DateTime.Now; pc.FundsValue.Add(fv); } pc.SaveChanges(); }