public async Task <IActionResult> MunicipalityAdd(long eventId)
        {
            DistrictVM result = new DistrictVM();

            result.MunicipalityId = eventId;
            return(PartialView(result));
        }
        public ActionResult Select()
        {
            string mode = Request.QueryString["Grid-mode"];

            if (!string.IsNullOrEmpty(mode))
            {
                return(this.RedirectToAction("Create"));
            }
            else
            {
                List <DistrictVM> viewModels           = new List <DistrictVM>();
                DistrictBAL       balObject            = new DistrictBAL();
                IQueryable <Entities.District> entites = balObject.GetAll();


                foreach (Entities.District entity in entites)
                {
                    DistrictVM viewModel = new DistrictVM();
                    viewModel.DistrictId   = entity.DistrictId;
                    viewModel.DistrictName = entity.DistrictName;
                    viewModel.StateName    = entity.StateName;
                    viewModel.CountryName  = entity.CountryName;
                    viewModel.Status       = entity.Status;
                    viewModel.Remark       = entity.Remark;
                    viewModels.Add(viewModel);
                }
                return(View(new GridModel <DistrictVM> {
                    Data = viewModels
                }));
            }
        }
        public ActionResult Edit(DistrictVM viewModel)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    Entities.District entity = new Entities.District();
                    entity.DistrictId   = viewModel.DistrictId;
                    entity.StateId      = viewModel.StateId;
                    entity.DistrictName = viewModel.DistrictName;
                    entity.Status       = viewModel.Status;
                    entity.Remark       = viewModel.Remark;

                    DistrictBAL balObject = new DistrictBAL();
                    balObject.Edit(entity);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    // AcademicYearBAL academicYearBAL = new AcademicYearBAL();
                    // viewModel.AcademicYears = from obj in academicYearBAL.GetAll() select new SelectListItem() { Text = obj.AcademicYearName, Value = obj.AcademicYearId.ToString() };

                    return(View(viewModel));
                }
            }
            catch
            {
                // AcademicYearBAL academicYearBAL = new AcademicYearBAL();
                // viewModel.AcademicYears = from obj in academicYearBAL.GetAll() select new SelectListItem() { Text = obj.AcademicYearName, Value = obj.AcademicYearId.ToString() };

                return(View());
            }
        }
 public ActionResult Create([Bind(Include = "Name")] DistrictVM districtVM)
 {
     if (ModelState.IsValid)
     {
         DistrictDTO districtDTO = Mapper.Map <DistrictDTO>(districtVM);
         DistrictService.Add(districtDTO);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Exemple #5
0
        // POST: api/Districts
        public HttpResponseMessage InsertDistrict(DistrictVM districtVM)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter");
            var result  = _iDistrictService.Insert(districtVM);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added");
            }
            return(message);
        }
 public bool Insert(DistrictVM districtVM)
 {
     if (string.IsNullOrWhiteSpace(districtVM.Name))
     {
         return(status);
     }
     else
     {
         return(iDistrictRepository.Insert(districtVM));
     }
 }
        public bool Insert(DistrictVM districtVM)
        {
            var push = new District(districtVM);
            //ini nih foreign key
            var getRegency = applicationContext.Regencies.SingleOrDefault(x => x.IsDelete == false && x.Id == districtVM.RegencyId);

            push.Regency = getRegency;
            applicationContext.Districts.Add(push);
            var result = applicationContext.SaveChanges();

            return(result > 0);
        }
        public bool Update(int id, DistrictVM districtVM)
        {
            var get        = Get(id);
            var getRegency = applicationContext.Regencies.SingleOrDefault(x => x.IsDelete == false && x.Id == districtVM.RegencyId);

            get.Regency = getRegency;
            get.Update(districtVM);
            applicationContext.Entry(get).State = EntityState.Modified;
            var result = applicationContext.SaveChanges();

            return(result > 0);
        }
        //
        // GET: /SysAdmin/District/Create
        public ActionResult Create()
        {
            DistrictVM viewModel = new DistrictVM();
            StateBAL   stateBAL  = new StateBAL();

            viewModel.States = from obj in stateBAL.GetAll() select new SelectListItem()
            {
                Text = obj.StateName, Value = obj.StateId.ToString()
            };
            viewModel.Status = true;
            return(View(viewModel));
        }
Exemple #10
0
 public bool Update(int id, DistrictVM districtVM)
 {
     if (string.IsNullOrWhiteSpace(districtVM.Name))
     {
         return(status);
     }
     else
     {
         var result = _districtRepository.Update(id, districtVM);
         return(result);
     }
 }
Exemple #11
0
 public bool Insert(DistrictVM districtVM)
 {
     if (string.IsNullOrWhiteSpace(districtVM.Name) || string.IsNullOrWhiteSpace(districtVM.RegencyId.ToString()))
     {
         return(status);
     }
     else
     {
         var result = _districtRepository.Insert(districtVM);
         return(result);
     }
 }
Exemple #12
0
 public ActionResult Edit([Bind(Include = "DistrictId,Title,CenterLatitude,CenterLongitude,MapZoom")] DistrictVM districtVM)
 {
     if (ModelState.IsValid)
     {
         var district = Mapper.Map <District>(districtVM);
         this.Data.Districts.Update(district);
         this.Data.SaveChanges();
         this.populator.clearDistrictCaches();
         return(RedirectToAction("Index"));
     }
     return(View(districtVM));
 }
        public IActionResult MergeDistrict(DistrictVM districtVM)
        {
            var result = new Result();

            try
            {
                var mergeDistrictResult = ServiceFactory.GeolocationManagement.MergeDistrict(districtVM);
                result.Success = mergeDistrictResult.Success;
                result.Message = mergeDistrictResult.Message;
            }
            catch (Exception ex)
            {
                result.Success = false;
            }
            return(Json(result));
        }
 public ActionResult Edit(int?id)
 {
     try
     {
         DistrictDTO districtDTO = DistrictService.Get(id);
         DistrictVM  districtVM  = Mapper.Map <DistrictVM>(districtDTO);
         return(View(districtVM));
     }
     catch (ArgumentNullException)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     catch (NotFoundException)
     {
         return(HttpNotFound());
     }
 }
        public bool Insert(DistrictVM districtVM)
        {
            var push         = new District(districtVM);
            var getRegencyId = myContext.Regencys.Find(districtVM.Regency_Id);

            push.Regency = getRegencyId;
            myContext.Districts.Add(push);
            var result = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            return(status);
        }
        public void InsertOrUpdate(DistrictVM districtVM)
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:12280/api/");
            var myContent   = JsonConvert.SerializeObject(districtVM);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            if (districtVM.Id.Equals(0))
            {
                var result = client.PostAsync("Districts", byteContent).Result;
            }
            else
            {
                var result = client.PutAsync("Districts/" + districtVM.Id, byteContent).Result;
            }
        }
Exemple #17
0
        public HttpResponseMessage UpdateDistrict(int id, DistrictVM districtVM)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request");

            if (string.IsNullOrWhiteSpace(id.ToString()))
            {
                message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
            }
            else
            {
                var get = _iDistrictService.Update(id, districtVM);
                if (get)
                {
                    message = Request.CreateResponse(HttpStatusCode.OK, get);
                    return(message);
                }
            }
            return(message);
        }
        //
        // GET: /SysAdmin/District/Details/5
        public ActionResult Details(int id)
        {
            DistrictVM  viewModel = new DistrictVM();
            DistrictBAL balObject = new DistrictBAL();
            IQueryable <Entities.District> entites = balObject.FindBy(a => a.DistrictId == id);

            if (entites != null && entites.Count() > 0)
            {
                Entities.District entity = entites.FirstOrDefault();
                viewModel.DistrictId   = entity.DistrictId;
                viewModel.DistrictName = entity.DistrictName;
                StateBAL stateBAL = new StateBAL();
                IQueryable <Entities.State> states = stateBAL.GetAll();
                viewModel.StateName = stateBAL.FindBy(c => c.StateId == entity.StateId).FirstOrDefault().StateName;
                viewModel.Status    = entity.Status;
                viewModel.Remark    = entity.Remark;
            }
            return(View(viewModel));
        }
        public bool Update(int id, DistrictVM districtVM)
        {
            var put          = Get(id);
            var getRegencyId = myContext.Regencys.Find(districtVM.Regency_Id);

            put.Regency = getRegencyId;
            put.Update(districtVM);
            myContext.Entry(put).State = EntityState.Modified;
            var result = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            return(status);
        }
        public ActionResult Index()
        {
            List <DistrictVM> viewModels           = new List <DistrictVM>();
            DistrictBAL       balObject            = new DistrictBAL();
            IQueryable <Entities.District> entites = balObject.GetAll();

            foreach (Entities.District entity in entites)
            {
                DistrictVM viewModel = new DistrictVM();
                viewModel.DistrictId   = entity.DistrictId;
                viewModel.DistrictName = entity.DistrictName;
                viewModel.StateName    = entity.StateName;
                viewModel.CountryName  = entity.CountryName;
                viewModel.Status       = entity.Status;
                viewModel.Remark       = entity.Remark;
                viewModels.Add(viewModel);
            }
            return(View(new GridModel <DistrictVM> {
                Data = viewModels
            }));
        }
        //
        // GET: /SysAdmin/District/Edit/5
        public ActionResult Edit(int id)
        {
            DistrictVM  viewModel = new DistrictVM();
            DistrictBAL balObject = new DistrictBAL();
            IQueryable <Entities.District> entites = balObject.FindBy(a => a.DistrictId == id);

            if (entites != null && entites.Count() > 0)
            {
                Entities.District entity = entites.FirstOrDefault();
                viewModel.DistrictId   = entity.DistrictId;
                viewModel.DistrictName = entity.DistrictName;
                viewModel.StateId      = entity.StateId;
                viewModel.StateName    = entity.StateName;
                viewModel.CountryName  = entity.CountryName;
                viewModel.CountryId    = entity.CountryId;
                viewModel.StateName    = entity.StateName;
                viewModel.Status       = entity.Status;
                viewModel.Remark       = entity.Remark;
            }
            return(View(viewModel));
        }
Exemple #22
0
        public BaseResult MergeDistrict(DistrictVM districtVM)
        {
            var result = new BaseResult();

            try
            {
                var district = Mapper.Map <District>(districtVM);
                if (districtVM.Id == 0)
                {
                    district.CreatedBy = AccountId;
                }
                district.ModifiedBy = AccountId;
                result.Success      = UnitOfWork.DistrictDao.Merge(district);
                result.Message      = GeneralSuccessMessage;
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = GeneralErrorMessage;
            }
            return(result);
        }
Exemple #23
0
        public List <DistrictVM> getAllDistrict()
        {
            try
            {
                var DistrictData = unitOfWork.TblDistrictInfoRepository.Get().ToList();

                List <DistrictVM> DistrictList = new List <DistrictVM>();

                foreach (var district in DistrictData)
                {
                    DistrictVM districtVM = new DistrictVM();
                    districtVM.DistrictId  = district.DistrictId;
                    districtVM.Description = district.Description;

                    DistrictList.Add(districtVM);
                }

                return(DistrictList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public bool Update(int id, DistrictVM districtVM)
 {
     return(iDistrictRepository.Update(id, districtVM));
 }
Exemple #25
0
 public void Update(DistrictVM districtVM)
 {
     this.Name       = districtVM.Name;
     this.UpdateDate = DateTime.Now.ToLocalTime();
 }
Exemple #26
0
 public District(DistrictVM districtVM)
 {
     this.Name       = districtVM.Name;
     this.CreateDate = DateTime.Now.ToLocalTime();
 }
Exemple #27
0
 public void Update(DistrictVM districtVM)
 {
     this.Name       = districtVM.Name;
     this.UpdateDate = DateTimeOffset.Now.LocalDateTime;
 }
Exemple #28
0
 public District(DistrictVM districtVM)
 {
     this.Name       = districtVM.Name;
     this.CreateDate = DateTimeOffset.Now.LocalDateTime;
 }
 public ActionResult MunicipalityDistrict_Create(DistrictVM municipality)
 {
     _municipalityBusiness.CreateMunicipalityDistrict(municipality);
     return(Content(""));
 }
 public ActionResult EditingMunicipalityDistrict_Update(DistrictVM model)
 {
     _municipalityBusiness.UpdateMunicipalityDistrict(model);
     return(Content(""));
 }