示例#1
0
        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));
            }
        }
示例#2
0
        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));
            }
        }