Exemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] BarangayViewModel barangay)
        {
            try
            {
                _barangayService.Update(barangay);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Exemplo n.º 2
0
        public bool Update(BarangayViewModel viewModel)
        {
            try
            {
                var model = _barangayRepository.GetById(viewModel.BarangayId);

                model.Code = viewModel.Code;
                model.Name = viewModel.Name;
                //model.UpdatedById = 1;
                model.UpdatedDate = DateTime.Now;

                _barangayRepository.Update(model);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public BarangayViewModel Get(int id)
        {
            try
            {
                var model = _barangayRepository.GetById(id);

                var viewModel = new BarangayViewModel
                {
                    BarangayId = model.BarangayId,
                    Code       = model.Code,
                    Name       = model.Name
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public bool Save(BarangayViewModel viewModel)
        {
            try
            {
                var model = new Barangay()
                {
                    Code     = viewModel.Code,
                    Name     = viewModel.Name,
                    IsActive = true,
                    //CreatedById = 1,
                    CreatedDate = DateTime.Now
                };

                _barangayRepository.Create(model);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }