public void Delete_Expence(Expence expence, string login) { var expence_for_del = _ctx.Expences.FirstOrDefault(d => d.Date_ == expence.Date_ && d.Sum == expence.Sum && d.Description == expence.Description && d.User == _ctx.Users.FirstOrDefault(u => u.Login == login) && d.Expence_Type == _ctx.Expances_Types.FirstOrDefault(e => e.Name == expence.Expence_Type.Name)); _ctx.Expences.Remove(expence_for_del); _ctx.SaveChanges(); }
public static void addExpence(Expence expence) { using (var context = new DatabaseEntities()) { context.Expences.Add(expence); context.SaveChanges(); } }
public static void deleteExpence(int expenceID) { using (var context = new DatabaseEntities()) { Expence e = context.Expences.FirstOrDefault(x => x.expenceID == expenceID); context.Expences.Remove(e); context.SaveChanges(); } }
public void Save_New_Expance(DateTime date, Decimal sum, string description, string Type, string login) { Expence expence = new Expence() { Date_ = date, Sum = sum, User = _ctx.Users.FirstOrDefault(u => u.Login == login), Expence_Type = _ctx.Expances_Types.FirstOrDefault(p => p.Name == Type), Description = description }; _ctx.Expences.Add(expence); _ctx.SaveChanges(); }