public bool CreateRoute(Route model) { try { var route = _db.Get<Route>().FirstOrDefault(x => x.Name == model.Name && x.CardPAN == model.CardPAN); if (route != null) { throw new Exception("Route with this Card PAN already exist"); } else { return _db.Add(new Route { SinkNode = model.SinkNode, CardPAN = model.CardPAN, Name = model.Name, Description = model.Description }); } } catch (Exception) { throw; } }
public bool EditRoute(Route model) { bool result = false; try { var route = _db.Get<Route>().Where(x =>x.Id==model.Id).FirstOrDefault(); if (route != null) { route.Name = model.Name; route.CardPAN = model.CardPAN; route.Description = model.Description; route.SinkNode = model.SinkNode; result = _db.Update(route); _db.Commit(); } return result; } catch (Exception) { _db.Rollback(); throw; } }