public void Update(RegistrationDm obj) { RegistrationDataMapper.Instance.Update(obj.ToDbDto()); var regs = GetByEvent(new EventDm { Id = obj.EventId }).Where(r => r.Accepted).ToArray(); if (regs.Length == 2) { var e = EventDataMapper.Instance.SelectById(obj.EventId); if (obj.Accepted) { try { // reservation var aidKitRes = new ReservationDbDto(); aidKitRes.EventId = obj.EventId; aidKitRes.ItemId = ItemDataMapper.Instance.SelectBigAidKit(e); ReservationDataMapper.Instance.Insert(aidKitRes); // TODO free small aid kit var reses = ReservationDataMapper.Instance.SelectAll(); foreach (var r in reses) { var item = ItemDataMapper.Instance.SelectById(r.ItemId); if (item.AidKit == 'S') { ReservationDataMapper.Instance.Delete(r); break; } } } catch (EntityNotFoundException) { } } } if (regs.Length == 1) { var e = EventDataMapper.Instance.SelectById(obj.EventId); if (!obj.Accepted) { try { var aidKitRes = new ReservationDbDto(); aidKitRes.EventId = obj.EventId; aidKitRes.ItemId = ItemDataMapper.Instance.SelectSmallAidKit(e); ReservationDataMapper.Instance.Insert(aidKitRes); // TODO free big aid kit var reses = ReservationDataMapper.Instance.SelectAll(); foreach (var r in reses) { var item = ItemDataMapper.Instance.SelectById(r.ItemId); if (item.AidKit == 'B') { ReservationDataMapper.Instance.Delete(r); break; } } } catch (EntityNotFoundException) { } } } }
public void Remove(RegistrationDm obj) { RegistrationDataMapper.Instance.Insert(obj.ToDbDto()); }