Exemple #1
0
        public IActionResult AddMasterBankAccountType()
        {
            try
            {
                AddMasterBankAccountTypeViewModel objAddMasterBankAccountTypeViewModel = new AddMasterBankAccountTypeViewModel();
                objAddMasterBankAccountTypeViewModel.Mode     = CommonFunction.Mode.SAVE;
                objAddMasterBankAccountTypeViewModel.IsActive = true;
                objAddMasterBankAccountTypeViewModel.MasterBankAccountTypeId    = CommonFunction.NextMasterId("ADMasterBankAccountType", apiBaseUrl);
                objAddMasterBankAccountTypeViewModel.MasterBankAccountTypeId    = 0;
                objAddMasterBankAccountTypeViewModel.MasterBankAccountTypeTitle = "";
                objAddMasterBankAccountTypeViewModel.MasterBankAccountCode      = "";
                //DropDownFillMethod();

                //Return View doesn't make a new requests, it just renders the view
                return(View("~/Views/Master/MasterBankAccountType/AddMasterBankAccountType.cshtml", objAddMasterBankAccountTypeViewModel));
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }
Exemple #2
0
        public IActionResult ViewMasterBankAccountType(long MasterBankAccountTypeId)
        {
            try
            {
                AddMasterBankAccountTypeViewModel objAddMasterBankAccountTypeViewModel = null;
                string        endpoint        = apiBaseUrl + "MasterBankAccountTypes/" + MasterBankAccountTypeId;
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

                if (HttpGetResponse != null)
                {
                    objAddMasterBankAccountTypeViewModel = JsonConvert.DeserializeObject <AddMasterBankAccountTypeViewModel>(HttpGetResponse.Result);
                }
                else
                {
                    objAddMasterBankAccountTypeViewModel = new AddMasterBankAccountTypeViewModel();
                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }

                //DropDownFillMethod();
                objAddMasterBankAccountTypeViewModel.Mode = CommonFunction.Mode.UPDATE;
                return(View("~/Views/Master/MasterBankAccountType/AddMasterBankAccountType.cshtml", objAddMasterBankAccountTypeViewModel));
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }
Exemple #3
0
        public IActionResult SaveMasterBankAccountType(AddMasterBankAccountTypeViewModel objAddMasterBankAccountTypeViewModel)
        {
            try
            {
                objAddMasterBankAccountTypeViewModel.EnterById    = 1;
                objAddMasterBankAccountTypeViewModel.EnterDate    = DateTime.Now;
                objAddMasterBankAccountTypeViewModel.ModifiedById = 1;
                objAddMasterBankAccountTypeViewModel.ModifiedDate = DateTime.Now;

                if (objAddMasterBankAccountTypeViewModel.IsActive == null)
                {
                    objAddMasterBankAccountTypeViewModel.IsActive = false;
                }

                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();

                if (ModelState.IsValid)
                {
                    string endpoint = apiBaseUrl + "MasterBankAccountTypes";

                    Task <string> HttpPostResponse = null;

                    if (objAddMasterBankAccountTypeViewModel.Mode == CommonFunction.Mode.SAVE)
                    {
                        HttpPostResponse = CommonFunction.PostWebAPI(endpoint, objAddMasterBankAccountTypeViewModel);
                        //Notification Message
                        //Session is used to store object
                        HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master BankAccountType", "Master BankAccountType Insert Successfully!", ""));
                    }
                    else if (objAddMasterBankAccountTypeViewModel.Mode == CommonFunction.Mode.UPDATE)
                    {
                        endpoint         = apiBaseUrl + "MasterBankAccountTypes/" + objAddMasterBankAccountTypeViewModel.MasterBankAccountTypeId;
                        HttpPostResponse = CommonFunction.PutWebAPI(endpoint, objAddMasterBankAccountTypeViewModel);

                        //Notification Message
                        //Session is used to store object
                        HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master BankAccountType", "Master BankAccountType Update Successfully!", ""));
                    }

                    if (HttpPostResponse != null)
                    {
                        objAddMasterBankAccountTypeViewModel = JsonConvert.DeserializeObject <AddMasterBankAccountTypeViewModel>(HttpPostResponse.Result);
                        _logger.LogInformation("Database Insert/Update: ");//+ JsonConvert.SerializeObject(objAddMasterBankAccountTypeViewModel)); ;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        //DropDownFillMethod();
                        ModelState.Clear();
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                        return(View("~/Views/Master/MasterBankAccountType/AddMasterBankAccountType.cshtml", objAddMasterBankAccountTypeViewModel));
                    }
                }
                else
                {
                    ModelState.Clear();
                    if (ModelState.IsValid == false)
                    {
                        ModelState.AddModelError(string.Empty, "Validation error. Please contact administrator.");
                    }

                    //DropDownFillMethod();

                    //Return View doesn't make a new requests, it just renders the view
                    return(View("~/Views/Master/MasterBankAccountType/AddMasterBankAccountType.cshtml", objAddMasterBankAccountTypeViewModel));
                }
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }