public IActionResult GenerarToma(TomaViewModel model) { try { var toma = new TbPrToma { IdBodega = model.IdBodega, FechaToma = model.FechaToma, Ordenado = model.Ordenado }; var tomas = service.GenerateTD(toma); foreach (var item in tomas) { item.IdInventarioNavigation.TbPrInventarioBodega = null; item.IdInventarioNavigation.TbPrAjusteInventario = null; item.IdInventarioNavigation.TbPrTomaDetalle = null; //item.IdInventarioNavigation.IdSubFamiliaNavigation.TbPrInventario = null; } //if(model.Ordenado == "producto") // return Ok(tomas.OrderBy(o=>o.IdInventarioNavigation.Descripcion)); //else return(Json(new { tomas = tomas, esInicial = service.ExisteTomaInicial((int)toma.IdBodega) })); } catch (Exception ex) { AltivaLog.Log.Insertar(ex.ToString(), "Error"); throw; } }
public IActionResult CrearToma() { ViewBag.existeTomaInicial = false; var toma = new TomaViewModel(); toma.Borrador = true; toma.Anulado = false; return(View("CrearEditarToma", toma)); }
public TbPrToma ViewModelToDomainEdit(TomaViewModel viewModel) { var domain = service.GetTomaByID(viewModel.Id); domain.Anulado = viewModel.Anulado; domain.Borrador = viewModel.Borrador; domain.EsInicial = viewModel.EsInicial; domain.FechaToma = viewModel.FechaToma; domain.IdBodega = viewModel.IdBodega; domain.Ordenado = viewModel.Ordenado; return(domain); }
public TbPrToma ViewModelToDomain(TomaViewModel viewModel) { return(new TbPrToma { Anulado = false, Borrador = viewModel.Borrador, EsInicial = viewModel.EsInicial, FechaCreacion = DateTime.Now, FechaToma = viewModel.FechaToma, Id = viewModel.Id, IdBodega = viewModel.IdBodega, IdUsuarioCreacion = viewModel.IdUsuarioCreacion, Ordenado = viewModel.Ordenado, TbPrTomaDetalle = ViewModelToDomainTD(viewModel.TomaDetalle), }); }
public IActionResult CrearEditarToma(TomaViewModel viewModel) { try { viewModel.Borrador = true; var toma = GestionaToma(viewModel); return(Json(new { success = true, idToma = toma.Id })); } catch (Exception ex) { AltivaLog.Log.Insertar(ex.ToString(), "Error"); throw; } }
public IActionResult AjustarInventario(TomaViewModel viewModel) { try { viewModel.Borrador = false; var toma = GestionaToma(viewModel); var ajuste = map.AjustarInventario(toma.Id); var kardex = kardexMap.CreateKardexAM(ajuste, (int)ajuste.Id); return(Json(new { success = true, idAjuste = ajuste.Id })); } catch (Exception ex) { AltivaLog.Log.Insertar(ex.ToString(), "Error"); throw; } }
private TbPrToma GestionaToma(TomaViewModel viewModel) { var toma = new TbPrToma(); if (viewModel.Id != 0) { toma = map.Update(viewModel); if (viewModel.TomaDetalle != null) { var tomaDetalle = map.UpdateTD(viewModel.TomaDetalle); } } else { toma = map.Create(viewModel); } return(toma); }
public TbPrToma Update(TomaViewModel viewModel) { return(service.Update(ViewModelToDomainEdit(viewModel))); }
public TbPrToma Create(TomaViewModel viewModel) { return(service.Save(ViewModelToDomain(viewModel))); }