//
        // GET: /POAMap/Details/5
        public ActionResult Details(string id)
        {
            var existingData = _kppbcbll.GetById(id);
            var model        = new PoaMapDetailViewModel
            {
                PoaMap      = Mapper.Map <POA_MAPDto>(existingData),
                CurrentMenu = PageInfo,
                MainMenu    = _mainMenu
            };

            return(View("Detail", model));
        }
        //
        // GET: /POAMap/Create
        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 PoaMapDetailViewModel
            {
                CurrentMenu = PageInfo,
                MainMenu    = _mainMenu,
                NppbckIds   = GlobalFunctions.GetNppbkcAll(_nppbkcbll),
                Plants      = GlobalFunctions.GetPlantAll(),
                POAs        = GlobalFunctions.GetPoaAll(_poabll)
            };

            return(View("Create", model));
        }
        //
        // GET: /POAMap/Edit/5
        public ActionResult Edit(int id)
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller)
            {
                return(RedirectToAction("Details", new { id }));
            }

            var existingData = _poaMapBLL.GetById(id);
            var model        = new PoaMapDetailViewModel
            {
                PoaMap      = Mapper.Map <POA_MAPDto>(existingData),
                CurrentMenu = PageInfo,
                MainMenu    = _mainMenu
            };

            model.NppbckIds = GlobalFunctions.GetNppbkcAll(_nppbkcbll);
            model.Plants    = GlobalFunctions.GetPlantAll();
            model.POAs      = GlobalFunctions.GetPoaAll(_poabll);
            return(View("Edit", model));
        }
        public ActionResult Create(PoaMapDetailViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                bool isExistApproval;
                var  existingData = _poaMapBLL.GetByNppbckId(model.PoaMap.NPPBKC_ID, model.PoaMap.WERKS, model.PoaMap.POA_ID);
                if (existingData != null)
                {
                    AddMessageInfo("data already exist", Enums.MessageInfoType.Warning);
                    return(RedirectToAction("Create"));
                }
                var data = Mapper.Map <POA_MAP>(model.PoaMap);
                data.CREATED_BY   = CurrentUser.USER_ID;
                data.CREATED_DATE = DateTime.Now;
                MASTER_DATA_APPROVAL approvalData;
                _masterDataAprovalBLL.MasterDataApprovalValidation((int)Enums.MenuList.POAMap, CurrentUser.USER_ID,
                                                                   new POA_MAP(), data, out isExistApproval, out approvalData, true);

                _masterDataAprovalBLL.SendEmailWorkflow(approvalData.APPROVAL_ID);
                //_poaMapBLL.Save(data);

                AddMessageInfo(Constans.SubmitMessage.Saved, Enums.MessageInfoType.Success);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error);
                model.CurrentMenu = PageInfo;
                model.MainMenu    = _mainMenu;
                model.NppbckIds   = GlobalFunctions.GetNppbkcAll(_nppbkcbll);
                model.Plants      = GlobalFunctions.GetPlantAll();
                model.POAs        = GlobalFunctions.GetPoaAll(_poabll);

                return(View(model));
            }
        }