Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
 public static async Task<List<opt_taxi_call>>Get()
 {
     try
     {
         using(NayooDbEntities e= new NayooDbEntities())
         {
             return e.opt_taxi_call.ToList();
         }
     }
     catch (Exception ex)
     {    
         throw new Exception(ExceptionHelper.ExceptionMessage(ex));
     }
 }
Exemplo n.º 5
0
 public static async Task<List<opt_guest_record>> Get()
 {
     try
     {
         using (NayooDbEntities e = new NayooDbEntities())
         {
             return e.opt_guest_record.OrderByDescending(o => o.updatedDate).ToList();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ExceptionHelper.ExceptionMessage(ex));
     }
 }
Exemplo n.º 6
0
 public static async Task<opt_inbox_message> Get(Int32 id)
 {
     try
     {
         using (NayooDbEntities e = new NayooDbEntities())
         {
             return e.opt_inbox_message.Where(x => x.messageId == id).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ExceptionHelper.ExceptionMessage(ex));
     }
 }
Exemplo n.º 7
0
        public static async Task<Users> Login(string UserName, string Password)
        {
            try
            {
                string _passswordEncrypt = PasswordHelper.Encryption(Password);
                using (NayooDbEntities e = new NayooDbEntities())
                {
                    var user = e.mst_user.Where(x => x.username.Equals(UserName) && x.password.Equals(_passswordEncrypt)).FirstOrDefault();
                    if (user == null)
                        throw new Exception("Not found user Account.");

                    if (user.isActive == false)
                        throw new Exception("User is inactive.");

                    return AutoMap<mst_user, Users>.Map(user);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        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));
            }
        } 
Exemplo n.º 9
0
        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));
            }
        }
Exemplo n.º 10
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));
            }
        }
Exemplo n.º 11
0
 public static async Task<opt_taxi_call> Get(Int32 id, string uniqueId)
 {
     try
     {
         using(NayooDbEntities e= new NayooDbEntities())
         {
             return e.opt_taxi_call.Where(x => x.callId == id && x.callUniqueId.Equals(uniqueId)).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {    
         throw new Exception(ExceptionHelper.ExceptionMessage(ex));
     }
 }