Exemplo n.º 1
0
        public IngPurchaseOrdersController()
        {
            _factory                = new PurchaseOrderFactory();
            _Supplierfactory        = new SupplierFactory();
            _Storefactory           = new StoreFactory();
            _defaultCurrencyFactory = new DefaultCurrencyFactory();
            _factoryTax             = new Shared.Factory.Settings.TaxFactory();
            //ViewBag.ListStore = GetListStore();
            //lstStore = ViewBag.ListStore;
            //listStoreId = lstStore.Select(x => x.Value).ToList();

            lstStore    = (List <StoreModels>)ViewBag.StoreID.Items;
            listStoreId = lstStore.Select(x => x.Id).ToList();

            //==========
            lstCompany    = GetListCompany();
            listCompanyId = lstCompany.Select(x => x.Value).ToList();

            var lstCurData = _defaultCurrencyFactory.GetListDefaultCurrency();

            foreach (var item in lstCurData)
            {
                lstCur.Add(new SelectListItem
                {
                    Value = item.Id,
                    Text  = item.Symbol
                });
            }
        }
Exemplo n.º 2
0
        public IngWorkOrdersController()
        {
            _factory                = new WorkOrderFactory();
            _Storefactory           = new StoreFactory();
            _defaultCurrencyFactory = new DefaultCurrencyFactory();

            ViewBag.ListStore = GetListStore();
            lstStore          = ViewBag.ListStore;
            listStoreId       = lstStore.Select(x => x.Value).ToList();
            //==========
            lstCompany    = GetListCompany();
            listCompanyId = lstCompany.Select(x => x.Value).ToList();

            var lstCurData = _defaultCurrencyFactory.GetListDefaultCurrency();

            foreach (var item in lstCurData)
            {
                lstCur.Add(new SelectListItem
                {
                    Value = item.Id,
                    Text  = item.Symbol
                });
            }
        }
Exemplo n.º 3
0
        public ActionResult Index(LoginModel model, string returnUrl = null)
        {
            try
            {
                if (Session["User"] != null)
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }

                if (ModelState.IsValid)
                {
                    bool        isExistUser = false;
                    UserFactory factoy      = new UserFactory();
                    UserSession userSession = new UserSession();
                    _userFactory.GetValueCommons(model.Email, model.Password, model.IsFormOtherLink, ref isExistUser, ref userSession);
                    if (isExistUser)
                    {
                        if (ConfigurationManager.AppSettings["MultiLocation"] != null)
                        {
                            //check location
                            var countryCode = _baseFactory.GetCountryCode();
                            ////check with setting from db
                            if (!string.IsNullOrEmpty(userSession.CountryCode) &&
                                countryCode.ToLower() != userSession.CountryCode.ToLower())
                            {
                                var isMultiLocation = bool.Parse(ConfigurationManager.AppSettings["MultiLocation"]);
                                if (isMultiLocation && !model.IsFormOtherLink)
                                {
                                    //model.UrlWebHost = "http://localhost:4040/";//"http://115.75.188.151:2020/";
                                    //userSession.UrlWebHost = "http://localhost:4040/";
                                    model.Password = CommonHelper.GetSHA512(model.Password);
                                    return(Redirect(userSession.UrlWebHost + "/Login/index2?langId=" + model.LanguageId + "&email=" + model.Email + "&pwd=" + model.Password));
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(userSession.WebHostUrl))
                        {
                            model.Password = CommonHelper.GetSHA512(model.Password);
                            return(Redirect(userSession.WebHostUrl + "/Login/index2?langId=" + model.LanguageId + "&email=" + model.Email + "&pwd=" + model.Password));
                        }
                        UserModels User    = factoy.IsCheckLogin(model.Email, model.Password, model.IsFormOtherLink);
                        bool       isValid = (User != null);
                        if (isValid)
                        {
                            UserModule roles = null;
                            if (!User.IsSuperAdmin)
                            {
                                roles = _UserRoleFactory.CheckModuleForEmp(User.UserId, User.ListOrganizationId[0]);
                                if (roles == null || string.IsNullOrEmpty(roles.Controller))
                                {
                                    ModelState.AddModelError("", "Email is not authorized to login");
                                    return(View(model));
                                }
                            }

                            if (User.IsSuperAdmin)
                            {
                                model.ListStoreID = User.ListStoreID;
                            }
                            else
                            {
                                model.ListStoreID = _UserRoleFactory.GetStoreEmpAccess(User.UserId);
                            }

                            //End Check Role of Account
                            //Check merchant extend here
                            userSession.ListMerchantExtends = factoy.GetListMerchantExtend(userSession.EmployeeConfigId);
                            if (userSession.ListMerchantExtends != null && userSession.ListMerchantExtends.Count > 0)
                            {
                                userSession.IsMerchantExtend = true;
                                var lstStoreExtend = (from p in userSession.ListMerchantExtends
                                                      where p.ListStoreIds.Any()
                                                      select p)
                                                     .SelectMany(p => p.ListStoreIds).ToList();

                                model.ListStoreID.AddRange(lstStoreExtend);
                            }
                            //End check merchant extend here

                            //UserSession userSession = new UserSession();
                            userSession.Email           = User.Email;
                            userSession.UserName        = User.Name;
                            userSession.UserId          = User.UserId;
                            userSession.UserType        = 0;
                            userSession.IsAuthenticated = true;
                            userSession.ImageUrl        = null;
                            if (!string.IsNullOrEmpty(User.ImageURL))
                            {
                                userSession.ImageUrl = User.ImageURL;
                            }
                            userSession.IndustryId   = model.IndustryId;
                            userSession.ListIndustry = User.ListIndustry;

                            userSession.ListOrganizationId = User.ListOrganizationId;
                            userSession.ListOrganizations  = User.ListOrganizations;
                            userSession.IsSuperAdmin       = User.IsSuperAdmin;
                            userSession.OrganizationName   = User.OrganizationName;

                            userSession.listStore = User.listStore;

                            //if (User.IsSuperAdmin)
                            //    model.ListStoreID = User.ListStoreID;
                            //else
                            //    model.ListStoreID = _UserRoleFactory.GetStoreEmpAccess(User.UserId);

                            userSession.ListStoreID = model.ListStoreID;
                            if (model.ListStoreID.Count == 1)
                            {
                                userSession.StoreId = model.ListStoreID[0];
                            }
                            model.StoreName = User.StoreName;

                            userSession.IndustryId     = "HQForFnB";
                            userSession.AppKey         = User.AppKey;
                            userSession.AppSecret      = User.AppSecret;
                            userSession.LanguageId     = model.LanguageId;
                            userSession.DefaultStoreId = model.ListStoreID.FirstOrDefault();
                            /*Get List Key Language*/

                            var lstLangData = _LanguageFactory.GetLanguageDataToTrans(model.LanguageId);
                            //var a = _LanguageFactory.GetLanguageDataToTranslateForLogin(model.LanguageId);
                            //var lstLangData = _LanguageFactory.GetListLanguageForText(model.LanguageId);
                            foreach (var item in lstLangData)
                            {
                                if (!userSession.ListLanguageText.ContainsKey(item.LanguageLinkName))
                                {
                                    userSession.ListLanguageText.Add(item.LanguageLinkName, item.Text);
                                }
                            }
                            userSession.RememberMe = model.RememberMe;

                            Commons._RememberMe = model.RememberMe;
                            if (model.RememberMe)
                            {
                                Commons._LanguageId = model.LanguageId;
                            }

                            ////=====End Get Language For DateTimePicker
                            userSession.ListSetting = User.ListSetting;

                            //update 18/12/2017

                            //// end update 18/12/2017
                            //userSession.WebUrlHost = "http://api.nupos.com.sg/nuweb";

                            // Get CurrencySymbol
                            DefaultCurrencyFactory _factory = new DefaultCurrencyFactory();
                            var    listCurrencies           = _factory.GetListDefaultCurrency(null, null, userSession.ListOrganizationId);
                            string currency = listCurrencies.Where(w => w.IsSelected).Select(s => s.Symbol).FirstOrDefault();
                            if (!string.IsNullOrEmpty(currency))
                            {
                                userSession.CurrencySymbol = currency;
                            }
                            else
                            {
                                userSession.CurrencySymbol = "$";
                            }

                            Session.Add("User", userSession);

                            NSLog.Logger.Info("Check Return URL", returnUrl);
                            if (returnUrl == null)
                            {
                                return(RedirectToAction("Index", "Home", new { area = "" }));
                            }
                            else
                            {
                                return(Redirect(returnUrl));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Email/Password is incorrect!");
                            model.ListLanguage = GetListLang(ref model);
                            return(View(model));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Email/Password is incorrect!");
                        model.ListLanguage = GetListLang(ref model);
                        return(View(model));
                    }
                }
                else
                {
                    model.ListLanguage = GetListLang(ref model);
                    NSLog.Logger.Info("!ModelState.IsValid", model);
                    return(View(model));// Return Error page
                }
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("Login Error", ex);
                //_logger.Error("Login Error: " + ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
Exemplo n.º 4
0
 public SDefaultCurrencyController()
 {
     _factory          = new DefaultCurrencyFactory();
     ViewBag.ListStore = GetListStore();
 }