public void addAppointment(Appointment a) { entities.Appointments.Add(a); entities.SaveChanges(); }
public void updateAppointment(Appointment a) { entities.Appointments.Attach(a); entities.Entry(a).State = EntityState.Modified; entities.SaveChanges(); }
private void bSave_Click(object sender, EventArgs e) { PersianDateFormatter pdf = new PersianDateFormatter(); AppointmentRepository appRepo = new AppointmentRepository(); ContractRepository cRepo = new ContractRepository(); Contract contract = cRepo.getContract(contractId); Appointment app = new Appointment(); string description = ""; int value = 0; foreach (var item in radCheckedDropDownList1.CheckedItems) { description += item.DisplayValue.ToString() + "/"; value += Convert.ToInt32(item.Value); } contract.ContractPayment += value; cRepo.updateContract(contract); app.ContractId = contractId; description = description.Remove(description.Length - 1); app.Description = description; app.AppointmentDate = pdf.convert(tDate.Text); TimeSpan ts = new TimeSpan(tTime.Value.TimeOfDay.Hours, tTime.Value.TimeOfDay.Minutes, 0); app.AppointmentTime = ts; appRepo.addAppointment(app); }