public object InsertarItemCodeSteelgo(ItemCodeSteelgoJson json, Sam3_Usuario usuario) { try { using (SamContext ctx = new SamContext()) { Sam3_ItemCodeSteelgo nuevoItem = new Sam3_ItemCodeSteelgo(); nuevoItem.Activo = true; nuevoItem.Area = json.Area; nuevoItem.CedulaID = json.CedulaID; nuevoItem.DescripcionEspanol = json.DescripcionEspanol; nuevoItem.DescripcionIngles = json.DescripcionIngles; //nuevoItem.Diametro1 = json.Diametro1; //nuevoItem.Diametro2 = json.Diametro2; nuevoItem.FamiliaAceroID = json.FamiliaAceroID; nuevoItem.FechaModificacion = DateTime.Now; nuevoItem.Peso = json.Peso; nuevoItem.UsuarioModificacion = usuario.UsuarioID; nuevoItem.Codigo = json.Codigo; ctx.Sam3_ItemCodeSteelgo.Add(nuevoItem); ctx.SaveChanges(); TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(nuevoItem.ItemCodeSteelgoID.ToString()); result.ReturnCode = 200; result.ReturnStatus = true; result.IsAuthenicated = true; return(result); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }
public object ActualizarItemCodeSteelgo(ItemCodeSteelgoJson json, Sam3_Usuario usuario) { try { using (SamContext ctx = new SamContext()) { Sam3_ItemCodeSteelgo itemBd = ctx.Sam3_ItemCodeSteelgo.Where(x => x.ItemCodeSteelgoID == json.ItemCodeSteelgoID) .AsParallel().SingleOrDefault(); itemBd.Area = json.Area; itemBd.CedulaID = json.CedulaID; itemBd.DescripcionEspanol = json.DescripcionEspanol; itemBd.DescripcionIngles = json.DescripcionIngles; //itemBd.Diametro1 = json.Diametro1; //itemBd.Diametro2 = json.Diametro2; itemBd.FamiliaAceroID = json.FamiliaAceroID; itemBd.FechaModificacion = DateTime.Now; itemBd.Peso = json.Peso; itemBd.UsuarioModificacion = usuario.UsuarioID; itemBd.Codigo = json.Codigo; ctx.SaveChanges(); TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add("Ok"); result.ReturnCode = 200; result.ReturnStatus = true; result.IsAuthenicated = true; return(result); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }
public object ObtenerDiametrosItemCodeSteelgo(string itemCode, Sam3_Usuario usuario) { try { using (SamContext ctx = new SamContext()) { int itemCodeID = itemCode != "" ? Convert.ToInt32(itemCode) : 0; ItemCodeSteelgoJson itemCodeSteelgo = (from ic in ctx.Sam3_ItemCode join rid in ctx.Sam3_Rel_ItemCode_Diametro on ic.ItemCodeID equals rid.ItemCodeID join rics in ctx.Sam3_Rel_ItemCode_ItemCodeSteelgo on rid.Rel_ItemCode_Diametro_ID equals rics.Rel_ItemCode_Diametro_ID join rids in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro on rics.Rel_ItemCodeSteelgo_Diametro_ID equals rids.Rel_ItemCodeSteelgo_Diametro_ID join ics in ctx.Sam3_ItemCodeSteelgo on rids.ItemCodeSteelgoID equals ics.ItemCodeSteelgoID join d1 in ctx.Sam3_Diametro on rids.Diametro1ID equals d1.DiametroID join d2 in ctx.Sam3_Diametro on rids.Diametro2ID equals d2.DiametroID where ic.ItemCodeID == itemCodeID select new ItemCodeSteelgoJson { Diametro1 = d1.Valor, Diametro2 = d2.Valor }).AsParallel().FirstOrDefault(); return(itemCodeSteelgo); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }
public object Put(ItemCodeSteelgoJson json, string token) { string payload = ""; string newToken = ""; bool tokenValido = ManageTokens.Instance.ValidateToken(token, out payload, out newToken); if (tokenValido) { JavaScriptSerializer ser = new JavaScriptSerializer(); Sam3_Usuario usuario = ser.Deserialize <Sam3_Usuario>(payload); return(ItemCodeSteelgoBd.Instance.ActualizarItemCodeSteelgo(json, usuario)); } else { TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(payload); result.ReturnCode = 401; result.ReturnStatus = false; result.IsAuthenicated = false; return(result); } }
/// <summary> /// Obtener el detalle de un item code steelgo /// </summary> /// <param name="itemCodeSteelgoID">item code steelgo seleccionado</param> /// <param name="usuario">usuario actual</param> /// <returns>objeto con la informacion del item code steelgo</returns> public object ObtenerDetalleitemCodeSteelgo(string itemCodeSteelgo, Sam3_Usuario usuario) { try { using (SamContext ctx = new SamContext()) { int idSteelgo = Convert.ToInt32(itemCodeSteelgo); ItemCodeSteelgoJson detalle = (from r in ctx.Sam3_ItemCodeSteelgo join rid in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro on r.ItemCodeSteelgoID equals rid.ItemCodeSteelgoID join d1 in ctx.Sam3_Diametro on rid.Diametro1ID equals d1.DiametroID join d2 in ctx.Sam3_Diametro on rid.Diametro2ID equals d2.DiametroID join c in ctx.Sam3_CatalogoCedulas on r.CedulaID equals c.CatalogoCedulasID join d in ctx.Sam3_Diametro on c.DiametroID equals d.DiametroID where r.Activo && c.Activo && rid.Activo && d1.Activo && d2.Activo && d.Activo && rid.Rel_ItemCodeSteelgo_Diametro_ID == idSteelgo select new ItemCodeSteelgoJson { Area = r.Area, DescripcionEspanol = r.DescripcionEspanol, DescripcionIngles = r.DescripcionIngles, Diametro1 = d1.Valor, Diametro2 = d2.Valor, Familia = (from fa in ctx.Sam3_FamiliaAcero where fa.FamiliaAceroID == r.FamiliaAceroID && fa.Activo && r.Activo select fa.Nombre).FirstOrDefault(), ItemCodeSteelgoID = rid.Rel_ItemCodeSteelgo_Diametro_ID, Peso = r.Peso, Codigo = r.Codigo, TipoAcero = (from fa in ctx.Sam3_FamiliaAcero join fm in ctx.Sam3_FamiliaMaterial on fa.FamiliaMaterialID equals fm.FamiliaMaterialID where fa.FamiliaAceroID == r.FamiliaAceroID && fa.Activo && fm.Activo select fm.Nombre).FirstOrDefault(), }).AsParallel().SingleOrDefault(); if (detalle != null) { string diametro = (from ricsd in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro join ics in ctx.Sam3_ItemCodeSteelgo on ricsd.ItemCodeSteelgoID equals ics.ItemCodeSteelgoID join cat in ctx.Sam3_CatalogoCedulas on ics.CedulaID equals cat.CatalogoCedulasID join d in ctx.Sam3_Diametro on cat.DiametroID equals d.DiametroID where ricsd.Rel_ItemCodeSteelgo_Diametro_ID == detalle.ItemCodeSteelgoID && ricsd.Activo && ics.Activo && cat.Activo && d.Activo select d.Valor.ToString()).AsParallel().SingleOrDefault(); string cedulaA = (from ricsd in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro join ics in ctx.Sam3_ItemCodeSteelgo on ricsd.ItemCodeSteelgoID equals ics.ItemCodeSteelgoID join cat in ctx.Sam3_CatalogoCedulas on ics.CedulaID equals cat.CatalogoCedulasID join ced in ctx.Sam3_Cedula on cat.CedulaA equals ced.CedulaID where ricsd.Rel_ItemCodeSteelgo_Diametro_ID == detalle.ItemCodeSteelgoID && ricsd.Activo && ics.Activo && cat.Activo && ced.Activo select ced.Codigo).AsParallel().SingleOrDefault(); string cedulaB = (from ricsd in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro join ics in ctx.Sam3_ItemCodeSteelgo on ricsd.ItemCodeSteelgoID equals ics.ItemCodeSteelgoID join cat in ctx.Sam3_CatalogoCedulas on ics.CedulaID equals cat.CatalogoCedulasID join ced in ctx.Sam3_Cedula on cat.CedulaB equals ced.CedulaID where ricsd.Rel_ItemCodeSteelgo_Diametro_ID == detalle.ItemCodeSteelgoID && ricsd.Activo && ics.Activo && cat.Activo && ced.Activo select ced.Codigo).AsParallel().SingleOrDefault(); string cedulaC = (from ricsd in ctx.Sam3_Rel_ItemCodeSteelgo_Diametro join ics in ctx.Sam3_ItemCodeSteelgo on ricsd.ItemCodeSteelgoID equals ics.ItemCodeSteelgoID join cat in ctx.Sam3_CatalogoCedulas on ics.CedulaID equals cat.CatalogoCedulasID join ced in ctx.Sam3_Cedula on cat.CedulaC equals ced.CedulaID where ricsd.Rel_ItemCodeSteelgo_Diametro_ID == detalle.ItemCodeSteelgoID && ricsd.Activo && ics.Activo && cat.Activo && ced.Activo select ced.Codigo).AsParallel().SingleOrDefault(); detalle.Cedula = diametro + " - " + cedulaA + " - " + cedulaB + " - " + cedulaC; } return(detalle); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }