public IActionResult AddMasterTimeZone()
        {
            try
            {
                AddMasterTimeZoneViewModel objAddMasterTimeZoneViewModel = new AddMasterTimeZoneViewModel();
                objAddMasterTimeZoneViewModel.Mode             = CommonFunction.Mode.SAVE;
                objAddMasterTimeZoneViewModel.IsActive         = true;
                objAddMasterTimeZoneViewModel.MasterTimeZoneId = CommonFunction.NextMasterId("ADMasterTimeZone", apiBaseUrl);
                objAddMasterTimeZoneViewModel.MasterTimeZoneId = 0;
                objAddMasterTimeZoneViewModel.TimeZoneTitle    = "";
                objAddMasterTimeZoneViewModel.TimeZoneOffset   = "";
                objAddMasterTimeZoneViewModel.HasDst           = true;
                //DropDownFillMethod();

                //Return View doesn't make a new requests, it just renders the view
                return(View("~/Views/Master/MasterTimeZone/AddMasterTimeZone.cshtml", objAddMasterTimeZoneViewModel));
            }
            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());
        }
        public IActionResult ViewMasterTimeZone(long MasterTimeZoneId)
        {
            try
            {
                AddMasterTimeZoneViewModel objAddMasterTimeZoneViewModel = null;
                string        endpoint        = apiBaseUrl + "MasterTimeZones/" + MasterTimeZoneId;
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

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

                //DropDownFillMethod();
                objAddMasterTimeZoneViewModel.Mode = CommonFunction.Mode.UPDATE;
                return(View("~/Views/Master/MasterTimeZone/AddMasterTimeZone.cshtml", objAddMasterTimeZoneViewModel));
            }
            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());
        }
        public IActionResult SaveMasterTimeZone(AddMasterTimeZoneViewModel objAddMasterTimeZoneViewModel)
        {
            try
            {
                objAddMasterTimeZoneViewModel.EnterById    = 1;
                objAddMasterTimeZoneViewModel.EnterDate    = DateTime.Now;
                objAddMasterTimeZoneViewModel.ModifiedById = 1;
                objAddMasterTimeZoneViewModel.ModifiedDate = DateTime.Now;

                if (objAddMasterTimeZoneViewModel.IsActive == null)
                {
                    objAddMasterTimeZoneViewModel.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 + "MasterTimeZones";

                    Task <string> HttpPostResponse = null;

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

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

                    if (HttpPostResponse != null)
                    {
                        objAddMasterTimeZoneViewModel = JsonConvert.DeserializeObject <AddMasterTimeZoneViewModel>(HttpPostResponse.Result);
                        _logger.LogInformation("Database Insert/Update: ");//+ JsonConvert.SerializeObject(objAddGenCodeTypeViewModel)); ;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        //DropDownFillMethod();
                        ModelState.Clear();
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                        return(View("~/Views/Master/MasterTimeZone/AddMasterTimeZone.cshtml", objAddMasterTimeZoneViewModel));
                    }
                }
                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/MasterTimeZone/AddMasterTimeZone.cshtml", objAddMasterTimeZoneViewModel));
                }
            }
            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());
        }