public ActionResult Create()
        {
            var            District       = _districtManager.GetAll();
            ThanaViewModel thanaViewModel = new ThanaViewModel();

            thanaViewModel.Districts = District;
            return(View(thanaViewModel));
        }
        // GET: Thana/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Thana          thana   = _thanaManager.GetById((int)id);
            ThanaViewModel thanaVM = new ThanaViewModel()
            {
                Id         = thana.Id,
                Name       = thana.Name,
                DistrictId = thana.DistrictId
            };

            ViewBag.DistrictId = new SelectList(_districtManager.GetAll(), "Id", "Name", thana.DistrictId);
            return(View(thanaVM));
        }
        // GET: Thana/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var            district = _districtManager.GetAll();
            Thana          thana    = _thanaManager.GetById((int)id);
            ThanaViewModel thanaVM  = new ThanaViewModel()
            {
                Id       = thana.Id,
                Name     = thana.Name,
                District = district.Where(x => x.Id == thana.DistrictId).FirstOrDefault()
            };

            return(View(thanaVM));
        }
        public ActionResult Index()
        {
            var thana    = _thanaManager.GetAll();
            var district = _districtManager.GetAll();

            List <ThanaViewModel> thanaViewModels = new List <ThanaViewModel>();

            foreach (var allthana in thana)
            {
                var thanaVM = new ThanaViewModel();
                thanaVM.Id       = allthana.Id;
                thanaVM.Name     = allthana.Name;
                thanaVM.District = district.Where(x => x.Id == allthana.DistrictId).FirstOrDefault();
                thanaViewModels.Add(thanaVM);
            }
            return(View(thanaViewModels));
        }
        public ActionResult Edit(ThanaViewModel thanaViewModel)
        {
            try
            {
                Thana thana = new Thana();
                thana.Id         = thanaViewModel.Id;
                thana.Name       = thanaViewModel.Name;
                thana.DistrictId = thanaViewModel.DistrictId;

                _thanaManager.Update(thana);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(ThanaViewModel thanaViewModel)
        {
            try
            {
                Thana thana = new Thana();
                thana.Name       = thanaViewModel.Name;
                thana.DistrictId = thanaViewModel.DistrictId;

                bool isSaved = _thanaManager.Add(thana);
                if (isSaved)
                {
                    TempData["msg"] = "Thana Saved Successfully";
                }

                return(RedirectToAction("Create"));
            }
            catch
            {
                return(View());
            }
        }