public async Task <IActionResult> Update([FromBody] BarangayViewModel barangay) { try { _barangayService.Update(barangay); return(Ok()); } catch (Exception ex) { return(BadRequest()); } }
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); } }
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); } }
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); } }