예제 #1
0
        public ResponeMerchantConfig RegisterAccountFromCSC(MerchantConfigApiModels info)
        {
            //_logger.Info(info);
            NSLog.Logger.Info("Start [RegisterAccountFromCSC] data.......................", info);

            var response = new ResponeMerchantConfig();

            if (info != null)
            {
                response = _POSMerchantConfigFactory.RegisterAccountFromCSC(info);
            }
            return(response);
        }
예제 #2
0
        public ResponeMerchantConfig InsertPosApiMerchantConfig(MerchantConfigApiModels info)
        {
            //_logger.Info(info);
            NSLog.Logger.Info("Start [Insert Pos Api Merchant Config] data.......................", info);

            var respoone = new ResponeMerchantConfig();

            if (info != null)
            {
                respoone = _POSMerchantConfigFactory.Insert(info);
            }
            return(respoone);
        }
예제 #3
0
        /*Merchant*/
        public ResponeMerchantConfig Insert(MerchantConfigApiModels info)
        {
            ResponeMerchantConfig result = new ResponeMerchantConfig();

            using (NuWebContext cxt = new NuWebContext())
            {
                using (var transaction = cxt.Database.BeginTransaction())
                {
                    try
                    {
                        var isExsitMerchant = cxt.G_POSAPIMerchantConfig.Any(x => x.POSAPIUrl.ToLower().Equals(info.POSAPIUrl.ToLower()));
                        if (isExsitMerchant)
                        {
                            NSLog.Logger.Info(string.Format("The merchant [{0}] already exist", info.POSAPIUrl));
                            return(result);
                        }

                        G_POSAPIMerchantConfig itemMerchantConfig = new G_POSAPIMerchantConfig();
                        /*string POSAPIMerchantConfigId =Guid.NewGuid().ToString();*/
                        string POSAPIMerchantConfigId = string.Empty;
                        if (string.IsNullOrEmpty(info.Id))
                        {
                            POSAPIMerchantConfigId = Guid.NewGuid().ToString();
                        }
                        else
                        {
                            POSAPIMerchantConfigId = info.Id;
                        }
                        itemMerchantConfig.Id            = POSAPIMerchantConfigId;
                        itemMerchantConfig.NuPOSInstance = info.NuPOSInstance;
                        itemMerchantConfig.POSAPIUrl     = info.POSAPIUrl;
                        itemMerchantConfig.FTPHost       = info.FTPHost;
                        itemMerchantConfig.FTPUser       = info.FTPUser;
                        itemMerchantConfig.FTPPassword   = info.FTPPassword;
                        itemMerchantConfig.ImageBaseUrl  = info.ImageBaseUrl;

                        itemMerchantConfig.BreakfastStart     = info.BreakfastStart;
                        itemMerchantConfig.BreakfastEnd       = info.BreakfastEnd;
                        itemMerchantConfig.LunchStart         = info.LunchStart;
                        itemMerchantConfig.LunchEnd           = info.LunchEnd;
                        itemMerchantConfig.DinnerStart        = info.DinnerStart;
                        itemMerchantConfig.DinnerEnd          = info.DinnerEnd;
                        itemMerchantConfig.CreatedDate        = DateTime.Now;
                        itemMerchantConfig.IsActived          = true;
                        itemMerchantConfig.POSInstanceVersion = info.POSInstanceVersion;

                        itemMerchantConfig.MorningStart = info.MorningStart;
                        itemMerchantConfig.MorningEnd   = info.MorningEnd;
                        itemMerchantConfig.MidDayStart  = info.MidDayStart;
                        itemMerchantConfig.MidDayEnd    = info.MidDayEnd;
                        List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>();
                        G_POSEmployeeConfig        itemEmpInsert     = null;
                        foreach (var item in info.ListEmployees)
                        {
                            itemEmpInsert = new G_POSEmployeeConfig();
                            if (string.IsNullOrEmpty(item.Id))
                            {
                                itemEmpInsert.Id = Guid.NewGuid().ToString();
                            }
                            else
                            {
                                itemEmpInsert.Id = item.Id;
                            }
                            //itemEmpInsert.Id = Guid.NewGuid().ToString();
                            itemEmpInsert.POSAPIMerchantConfigId = POSAPIMerchantConfigId;
                            itemEmpInsert.UserName    = item.UserName;
                            itemEmpInsert.Password    = CommonHelper.GetSHA512(item.Password);
                            itemEmpInsert.CreatedDate = DateTime.Now;
                            itemEmpInsert.IsActived   = true;
                            lstInsertEmployee.Add(itemEmpInsert);
                        }
                        cxt.G_POSAPIMerchantConfig.Add(itemMerchantConfig);
                        cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee);
                        cxt.SaveChanges();
                        transaction.Commit();

                        result.IsOk         = true;
                        result.POSIntanceID = itemMerchantConfig.Id;

                        NSLog.Logger.Info("Insert [Insert Pos Api Merchant Config] data success", info);
                    }
                    catch (Exception ex)
                    {
                        NSLog.Logger.Error("Insert [Insert Pos Api Merchant Config] data fail", ex);
                        //_logger.Error(ex);
                        result.IsOk = false;
                        transaction.Rollback();
                    }
                    finally
                    {
                        if (cxt != null)
                        {
                            cxt.Dispose();
                        }
                    }
                }
            }
            //var jsonContent = JsonConvert.SerializeObject(info);
            //_baseFactory.InsertTrackingLog("G_POSAPIMerchantConfig", jsonContent, info.NuPOSInstance, result);

            return(result);
        }
예제 #4
0
        public async Task <ResponeMerchantConfig> GetListMerchantConfig()
        {
            ResponeMerchantConfig result = new ResponeMerchantConfig();

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    var listPOSAPIMerchantConfig = (from merchant in cxt.G_POSAPIMerchantConfig
                                                    where merchant.IsActived
                                                    select new MerchantConfigApiModels
                    {
                        BreakfastEnd = merchant.BreakfastEnd,
                        BreakfastStart = merchant.BreakfastStart,
                        DinnerEnd = merchant.DinnerEnd,
                        DinnerStart = merchant.DinnerStart,
                        FTPHost = merchant.FTPHost,
                        FTPPassword = merchant.FTPPassword,
                        FTPUser = merchant.FTPUser,
                        Id = merchant.Id,
                        ImageBaseUrl = merchant.ImageBaseUrl,
                        LunchEnd = merchant.LunchEnd,
                        LunchStart = merchant.LunchStart,
                        //MerchantName = merchant.MerchantName,
                        POSAPIUrl = merchant.POSAPIUrl,
                        IsActived = merchant.IsActived,
                        CreatedDate = merchant.CreatedDate,
                        POSInstanceVersion = merchant.POSInstanceVersion,

                        MorningStart = merchant.MorningStart.HasValue? merchant.MorningStart.Value: new TimeSpan(),
                        MorningEnd = merchant.MorningEnd.HasValue? merchant.MorningEnd.Value: new TimeSpan(),
                        MidDayStart = merchant.MidDayStart.HasValue? merchant.MidDayStart.Value: new TimeSpan(),
                        MidDayEnd = merchant.MidDayEnd.HasValue? merchant.MidDayEnd.Value: new TimeSpan(),
                    }).ToList();
                    var listPOSEmployeeConfig = (from employee in cxt.G_POSEmployeeConfig
                                                 where employee.IsActived
                                                 select new EmployeeConfigApiModels
                    {
                        Id = employee.Id,
                        IsActived = employee.IsActived,
                        UserName = employee.UserName,
                        POSAPIMerchantConfigId = employee.POSAPIMerchantConfigId,
                        CreatedDate = employee.CreatedDate
                    }).ToList();

                    listPOSAPIMerchantConfig.ForEach(x =>
                    {
                        x.ListEmployees = listPOSEmployeeConfig.Where(z => z.POSAPIMerchantConfigId.Equals(x.Id)).ToList();
                    });
                    result.IsOk = true;
                    result.Data = listPOSAPIMerchantConfig;

                    NSLog.Logger.Info("Insert [Get List Merchant Config] data success");
                }
                catch (Exception ex)
                {
                    NSLog.Logger.Error("Insert [Get List Merchant Config] data fail", ex);
                    //_logger.Error(ex.Message);
                }
                finally
                {
                }
            }
            return(result);
        }
예제 #5
0
        //2018-01-02
        public ResponeMerchantConfig RegisterAccountFromCSC(MerchantConfigApiModels info)
        {
            ResponeMerchantConfig result = new ResponeMerchantConfig();

            using (NuWebContext cxt = new NuWebContext())
            {
                using (var transaction = cxt.Database.BeginTransaction())
                {
                    try
                    {
                        var merchant = cxt.G_POSAPIMerchantConfig.Where(x => x.POSAPIUrl == info.POSAPIUrl && x.IsActived).FirstOrDefault();
                        if (merchant != null)
                        {
                            List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>();
                            G_POSEmployeeConfig        itemEmpInsert     = null;
                            foreach (var item in info.ListEmployees)
                            {
                                itemEmpInsert = new G_POSEmployeeConfig();
                                if (string.IsNullOrEmpty(item.Id))
                                {
                                    itemEmpInsert.Id = Guid.NewGuid().ToString();
                                }
                                else
                                {
                                    itemEmpInsert.Id = item.Id;
                                }
                                itemEmpInsert.POSAPIMerchantConfigId = merchant.Id;
                                itemEmpInsert.UserName    = item.UserName;
                                itemEmpInsert.Password    = item.Password;
                                itemEmpInsert.CreatedDate = DateTime.Now;
                                itemEmpInsert.IsActived   = true;
                                lstInsertEmployee.Add(itemEmpInsert);
                            }
                            cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee);
                        }
                        else
                        {
                            G_POSAPIMerchantConfig itemMerchantConfig = new G_POSAPIMerchantConfig();

                            itemMerchantConfig.Id            = info.Id;
                            itemMerchantConfig.NuPOSInstance = info.NuPOSInstance;
                            itemMerchantConfig.POSAPIUrl     = info.POSAPIUrl;
                            itemMerchantConfig.FTPHost       = info.FTPHost;
                            itemMerchantConfig.FTPUser       = info.FTPUser;
                            itemMerchantConfig.FTPPassword   = info.FTPPassword;
                            itemMerchantConfig.ImageBaseUrl  = info.ImageBaseUrl;

                            itemMerchantConfig.BreakfastStart     = info.BreakfastStart;
                            itemMerchantConfig.BreakfastEnd       = info.BreakfastEnd;
                            itemMerchantConfig.LunchStart         = info.LunchStart;
                            itemMerchantConfig.LunchEnd           = info.LunchEnd;
                            itemMerchantConfig.DinnerStart        = info.DinnerStart;
                            itemMerchantConfig.DinnerEnd          = info.DinnerEnd;
                            itemMerchantConfig.CreatedDate        = DateTime.Now;
                            itemMerchantConfig.IsActived          = true;
                            itemMerchantConfig.POSInstanceVersion = info.POSInstanceVersion;

                            itemMerchantConfig.MorningStart = info.MorningStart;
                            itemMerchantConfig.MorningEnd   = info.MorningEnd;
                            itemMerchantConfig.MidDayStart  = info.MidDayStart;
                            itemMerchantConfig.MidDayEnd    = info.MidDayEnd;
                            List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>();
                            G_POSEmployeeConfig        itemEmpInsert     = null;
                            foreach (var item in info.ListEmployees)
                            {
                                itemEmpInsert = new G_POSEmployeeConfig();
                                if (string.IsNullOrEmpty(item.Id))
                                {
                                    itemEmpInsert.Id = Guid.NewGuid().ToString();
                                }
                                else
                                {
                                    itemEmpInsert.Id = item.Id;
                                }
                                //itemEmpInsert.Id = Guid.NewGuid().ToString();
                                itemEmpInsert.POSAPIMerchantConfigId = info.Id;
                                itemEmpInsert.UserName    = item.UserName;
                                itemEmpInsert.Password    = item.Password;
                                itemEmpInsert.CreatedDate = DateTime.Now;
                                itemEmpInsert.IsActived   = true;
                                lstInsertEmployee.Add(itemEmpInsert);
                            }
                            cxt.G_POSAPIMerchantConfig.Add(itemMerchantConfig);
                            cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee);
                        }
                        cxt.SaveChanges();
                        transaction.Commit();

                        result.IsOk         = true;
                        result.POSIntanceID = info.Id;

                        NSLog.Logger.Info("Insert [RegisterAccountFromCSC] data success", info);
                    }
                    catch (Exception ex)
                    {
                        NSLog.Logger.Error("Insert [RegisterAccountFromCSC] data fail", ex);
                        //_logger.Error(ex);
                        result.IsOk = false;
                        transaction.Rollback();
                    }
                    finally
                    {
                        if (cxt != null)
                        {
                            cxt.Dispose();
                        }
                    }
                }
            }

            return(result);
        }