public MyResponse Add([FromBody] ServicioViewModel ServicioAgregar) { MyResponse Res = new MyResponse(); try { if (ServicioAgregar != null) { var resultado = db.clientes.FirstOrDefault(p => p.Id == ServicioAgregar.fk_Cliente.Id); Models.Servicios oServicio = new Models.Servicios(); oServicio.valorxHora = ServicioAgregar.valorxHora; oServicio.nombreServicio = ServicioAgregar.nombreServicio; oServicio.fk_Cliente = resultado; db.servicios.Add(oServicio); db.SaveChanges(); Res.Success = 1; } else { Res.Message = "Sericio Nulo"; } } catch (Exception e) { Res.Success = 0; Res.Message = e.Message; } return(Res); }
public FrmServicio() { InitializeComponent(); Model = ServiceLocator.Instance.Resolve <ServicioViewModel>(); btnNuevo.Visible = CurrentSession.PermisoUsuario("16"); btnModificar.Visible = CurrentSession.PermisoUsuario("17"); btnEliminar.Visible = CurrentSession.PermisoUsuario("18"); }
public ActionResult Edit(ServicioViewModel servicioViewModel) { using (UnidadDeTrabajo <Servicio> unidad = new UnidadDeTrabajo <Servicio>(new BDContext())) { unidad.genericDAL.Update(this.Convertir(servicioViewModel)); unidad.Complete(); } return(RedirectToAction("Index")); }
}// FIN DE CONVERTIR private Servicio Convertir(ServicioViewModel servicioViewModel) { Servicio ServicioViewModel = new Servicio { Servicio_ID = servicioViewModel.Servicio_ID, Nombre = servicioViewModel.Nombre, Precio = servicioViewModel.Precio }; return(ServicioViewModel); }
// GET: Servicio private ServicioViewModel Convertir(Servicio servicio) { ServicioViewModel servicioViewModel = new ServicioViewModel { Servicio_ID = servicio.Servicio_ID, Nombre = servicio.Nombre, Precio = (double)servicio.Precio }; return(servicioViewModel); }// FIN DE CONVERTIR
public IActionResult Upsert(int?id) { servicioViewModel = new ServicioViewModel() { Servicio = new Servicio(), ListadoCategorias = _unitOfWork.categoria.ObtenerListadoCategoriasParaDropDown(), ListadoFrecuencias = _unitOfWork.frecuencia.ObtenerListadoFrecuenciasParaDropDown(), }; if (id != null) { // El usuario requiere editar el servicio servicioViewModel.Servicio = _unitOfWork.servicio.Get(id.GetValueOrDefault()); } return(View(servicioViewModel)); }
public bool UpdateServicio(ServicioViewModel servicioViewModel) { try { Servicio s1 = context.servicios.Find(servicioViewModel.ServicioId); s1.Cost = servicioViewModel.Cost; s1.Description = servicioViewModel.Description; s1.Name = servicioViewModel.Name; s1.ServiceCategory = context.categories.Where(x => x.CategoryName == servicioViewModel.CategoryName).First(); s1.ServiceCategoryId = s1.ServiceCategory.ServiceCategoryId; context.Update(s1); context.SaveChanges(); } catch (System.Exception) { return(false); } return(true); }
public MyResponse Modificar([FromBody] ServicioViewModel ServicioModificar, int id) { MyResponse Res = new MyResponse(); try {/* * db.Entry(ClienteModificar).State = EntityState.Modified; * db.SaveChanges();*/ var ServicioExistente = db.servicios.FirstOrDefault(p => p.Id == ServicioModificar.Id); if (ServicioExistente != null) { if (id == ServicioModificar.Id) { ServicioExistente.nombreServicio = ServicioModificar.nombreServicio; ServicioExistente.valorxHora = ServicioModificar.valorxHora; db.SaveChanges(); Res.Success = 1; } else { Res.Success = 0; Res.Message = "Error Diferentes Servicios"; } } else { Res.Success = 0; Res.Message = "Error cliente nulo"; } } catch (Exception e) { Res.Success = 0; Res.Message = e.Message; } return(Res); }
public ActionResult Put([FromBody] ServicioViewModel servicioViewModel) { return(Ok( servicioService.UpdateServicio(servicioViewModel) )); }
public MyResponse Add([FromBody] ServicioViewModel model) { return(_servicioService.Add(model)); }
public bool UpdateServicio(ServicioViewModel servicioViewModel) { return(servicioRepository.UpdateServicio(servicioViewModel)); }