public void AddAttendance(Client client, float price, DateTime date) { if (CheckAttendance(client, date)) { //Attendance by cash if (client.Subscription == null) { Attendance att = new Attendance(); att.Client = client; att.AttendancePrice = price; att.DateVisit = date; att.Payment = price.ToString(); DriveContext.Attendance.Add(att); string message = string.Format("Посещение клиента \"{0}\" зафиксировано: {1} - {2}", client, date.ToShortDateString(), price ); OnAttendanceFixed(message); DriveContext.SaveChanges(); } //Attendance by subscription else { Attendance att = new Attendance(); att.Client = client; att.AttendancePrice = 0; att.DateVisit = date; att.Payment = "A"; DriveContext.Attendance.Add(att); string message = string.Format("Посещение клиента \"{0}\" зафиксировано {1}", client, date.ToShortDateString() ); OnAttendanceFixed(message); client.Subscription.SubscriptionCountExcercise--; if (client.Subscription.SubscriptionCountExcercise == 0) { string mess = string.Format("Абонемент клиента \"{0}\" закрыт.", client ); client.Subscription = null; OnSubscriptionClosed(mess); } DriveContext.SaveChanges(); } } else { throw new InvalidOperationException($"Посещение клиента \"{client}\" - {date.ToShortDateString()} уже зафиксировано!"); } }
public void SaveDataContext() { DriveContext.SaveChanges(); }
public void AddGroup(Group group) { DriveContext.Group.Add(group); DriveContext.SaveChanges(); }