private BrandRegistrationCreateViewModel InitCreate(BrandRegistrationCreateViewModel model)
        {
            model.MainMenu    = _mainMenu;
            model.CurrentMenu = PageInfo;

            model.StickerCodeList = GlobalFunctions.GetStickerCodeList();
            //model.PlantList = GlobalFunctions.GetVirtualPlantList();
            model.PersonalizationCodeList = GlobalFunctions.GetPersonalizationCodeList();
            model.ProductCodeList         = GlobalFunctions.GetProductCodeList(_productBll);
            model.SeriesList         = GlobalFunctions.GetSeriesCodeList(_masterBll);
            model.MarketCodeList     = GlobalFunctions.GetMarketCodeList(_masterBll);
            model.CountryCodeList    = GlobalFunctions.GetCountryList();
            model.HjeCurrencyList    = GlobalFunctions.GetCurrencyList();
            model.TariffCurrencyList = GlobalFunctions.GetCurrencyList();
            model.GoodTypeList       = GlobalFunctions.GetGoodTypeList(_goodTypeBll);
            model.BahanKemasanList   = GlobalFunctions.GetBahanKemasanList(_brandRegistrationBll);
            model.FaCodeList         = GlobalFunctions.GetStickerCodeList();

            if (!string.IsNullOrEmpty(model.StickerCode))
            {
                var data = _materialBll.getAllPlant(model.StickerCode);
                model.PlantList = new SelectList(data, "WERKS", "WERKS - NAME1");
            }

            return(model);
        }
        public ActionResult Create(BrandRegistrationCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool isExist;
                var  dbBrand = new ZAIDM_EX_BRAND();

                dbBrand = Mapper.Map <ZAIDM_EX_BRAND>(model);
                if (dbBrand.STICKER_CODE.Length > 18)
                {
                    dbBrand.STICKER_CODE = dbBrand.STICKER_CODE.Substring(0, 17);
                }
                dbBrand.FA_CODE         = model.FaCode.Trim();
                dbBrand.STICKER_CODE    = model.StickerCode.Trim();
                dbBrand.CREATED_DATE    = DateTime.Now;
                dbBrand.CREATED_BY      = CurrentUser.USER_ID;
                dbBrand.IS_FROM_SAP     = model.IsFromSAP;
                dbBrand.HJE_IDR         = model.HjeValueStr == null ? 0 : Convert.ToDecimal(model.HjeValueStr);
                dbBrand.TARIFF          = model.TariffValueStr == null ? 0 : Convert.ToDecimal(model.TariffValueStr);
                dbBrand.CONVERSION      = model.ConversionValueStr == null ? 0 : Convert.ToDecimal(model.ConversionValueStr);
                dbBrand.PRINTING_PRICE  = model.PrintingPrice == null ? 0 : Convert.ToDecimal(model.PrintingPriceValueStr);
                dbBrand.STATUS          = model.IsActive;
                dbBrand.PACKED_ADJUSTED = model.IsPackedAdjusted;
                dbBrand.BAHAN_KEMASAN   = string.IsNullOrEmpty(model.BahanKemasan) ? null : model.BahanKemasan.Trim();
                if (!string.IsNullOrEmpty(dbBrand.PER_CODE_DESC))
                {
                    dbBrand.PER_CODE_DESC = model.PersonalizationCodeDescription.Split('-')[1];
                }

                try
                {
                    MASTER_DATA_APPROVAL approvalData;
                    _masterDataAprovalBLL.MasterDataApprovalValidation((int)Enums.MenuList.BrandRegistration,
                                                                       CurrentUser.USER_ID, new ZAIDM_EX_BRAND(), dbBrand, out isExist, out approvalData, true);
                    // AddHistoryCreate(dbBrand.WERKS, dbBrand.FA_CODE, dbBrand.STICKER_CODE);

                    //_brandRegistrationBll.Save(dbBrand);

                    _masterDataAprovalBLL.SendEmailWorkflow(approvalData.APPROVAL_ID);
                    AddMessageInfo(Constans.SubmitMessage.Saved, Enums.MessageInfoType.Success);
                    return(RedirectToAction("Index"));
                }
                catch (BLLException ex)
                {
                    AddMessageInfo(ex.Message, Enums.MessageInfoType.Error);
                }
                catch (Exception)
                {
                    AddMessageInfo("Save Failed.", Enums.MessageInfoType.Error);
                }
            }

            InitCreate(model);

            return(View(model));
        }
        public ActionResult Create()
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller)
            {
                AddMessageInfo("Operation not allow", Enums.MessageInfoType.Error);
                return(RedirectToAction("Index"));
            }

            var model = new BrandRegistrationCreateViewModel();

            model = InitCreate(model);

            model.IsActive = true;
            return(View(model));
        }