public static async Task<opt_taxi_call> Add(opt_taxi_call entity) { try { using(TransactionScope scope= new TransactionScope()) { using(NayooDbEntities e =new NayooDbEntities()) { A: string _uniqueId = Helper.NewUniqueId; bool Ok = e.opt_taxi_call.Any(x => x.callUniqueId.Equals(_uniqueId)); if (Ok) goto A; entity.callUniqueId = _uniqueId; e.opt_taxi_call.Add(entity); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Save Taxi call not complete !"); scope.Complete(); return entity; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }
public static async Task<bool> Modify(opt_guest_record entity) { try { using (TransactionScope scope = new TransactionScope()) { using (NayooDbEntities e = new NayooDbEntities()) { var current = e.opt_guest_record.Where(x => x.recordId == entity.recordId && x.recordUniqueId.Equals(entity.recordUniqueId)).FirstOrDefault(); if (current == null) throw new Exception("Not found this object !"); entity.updatedDate = DateTime.Now; e.Entry(entity).CurrentValues.SetValues(current); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Record guest not complete !"); scope.Complete(); return true; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }
public static async Task<opt_guest_record> Add(opt_guest_record entity) { try { using (TransactionScope scope = new TransactionScope()) { using (NayooDbEntities e = new NayooDbEntities()) { A: string _guidId = Helper.NewUniqueId; bool Ok = e.opt_guest_record.Any(x => x.recordUniqueId.Equals(_guidId)); if (Ok) goto A; entity.isActive = true; entity.recordUniqueId = _guidId; entity.createdDate = DateTime.Now; entity.updatedDate = DateTime.Now; entity.inDate = DateTime.Now; e.opt_guest_record.Add(entity); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Record guest not complete !"); scope.Complete(); return entity; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }
public static async Task<mst_contact> Post(mst_contact entity) { try { using (TransactionScope scope = new TransactionScope()) { using (NayooDbEntities e = new NayooDbEntities()) { e.mst_contact.Add(entity); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Save contact not complete !"); scope.Complete(); return entity; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }
public static async Task<bool> Modify(opt_inbox_message entity) { try { using (TransactionScope scope = new TransactionScope()) { using (NayooDbEntities e = new NayooDbEntities()) { e.opt_inbox_message.Add(entity); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Save Inbox Message not complete !"); scope.Complete(); return true; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }
public static async Task<bool> Modify(opt_taxi_call entity) { try { using (TransactionScope scope = new TransactionScope()) { using (NayooDbEntities e = new NayooDbEntities()) { var _taxiCall = e.opt_taxi_call.Where(x => x.callId == entity.callId && x.callUniqueId.Equals(entity.callUniqueId)).FirstOrDefault(); e.Entry(entity).CurrentValues.SetValues(_taxiCall); var result = await e.SaveChangesAsync(); if (result <= 0) throw new Exception("Taxi call not complete !"); scope.Complete(); return true; } } } catch (DbEntityValidationException ex) { throw new Exception(ExceptionHelper.ExceptionMessage(ex)); } }