public IHttpActionResult PostEMI(EMI eMI) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EMIS.Add(eMI); try { db.SaveChanges(); } catch (DbUpdateException) { if (EMIExists(eMI.EmisCode)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = eMI.EmisCode }, eMI)); }
public IHttpActionResult PostInfraSpec([FromBody] string infraSpec) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } InfraSpecsModel sm = JsonConvert.DeserializeObject <InfraSpecsModel>(infraSpec); EMI emi = new EMI() { EmisCode = sm.Generalmodel.Emi.EmisCode, NameOfSchool = sm.Generalmodel.Emi.NameOfSchool, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow }; db.EMIS.Add(emi); db.SaveChanges(); Comment c = new Comment() { Entity = sm.Generalmodel.Comment.Entity, SurveyID = sm.Generalmodel.Comment.SurveyID, Section = sm.Generalmodel.Comment.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, Comments = sm.Generalmodel.Comment.Comments }; db.Comments.Add(c); db.SaveChanges(); SpecialFacility sf = new SpecialFacility() { Entity = sm.Generalmodel.Specialfacility.Entity, SurveyID = sm.Generalmodel.Specialfacility.SurveyID, Section = sm.Generalmodel.Specialfacility.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, AnyFacilitiesForDisableStudents = sm.Generalmodel.Specialfacility.AnyFacilitiesForDisableStudents, Description = sm.Generalmodel.Specialfacility.Description }; db.SpecialFacilities.Add(sf); db.SaveChanges(); List <Picture> res = sm.Generalmodel.Img.Select(x => new Picture { Entity = x.Entity, SurveyID = x.SurveyID, Section = x.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, Picture1 = x.Picture1 }).ToList(); db.Pictures.AddRange(res); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public IHttpActionResult PutEMI(string id, EMI eMI) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eMI.EmisCode) { return(BadRequest()); } db.Entry(eMI).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EMIExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Método de inserción /// </summary> /// <param name="Entidad">Entidad a guardar en la tabla</param> /// <returns>Cadena de texto con el resultado correspondiente.</returns> public bool Agregar(EMI emi, EMI_FACTOR_CRIMINODIAGNOSTICO Entidad) { try { using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted })) { Context.EMI_FACTOR_CRIMINODIAGNOSTICO.Add(Entidad); //Cambiamos el estatus a completo Context.EMI.Attach(emi); Context.Entry(emi).Property(x => x.ESTATUS).IsModified = true; Context.SaveChanges(); transaccion.Complete(); return(true); } //if (Insert(Entidad)) // return true; } catch (Exception ex) { throw new ApplicationException(ex.Message); } return(false); }
public IHttpActionResult GetEMI(string id) { EMI eMI = db.EMIS.Find(id); if (eMI == null) { return(NotFound()); } return(Ok(eMI)); }
public IHttpActionResult DeleteEMI(string id) { EMI eMI = db.EMIS.Find(id); if (eMI == null) { return(NotFound()); } db.EMIS.Remove(eMI); db.SaveChanges(); return(Ok(eMI)); }
private List <EMI> CabeceraEMI(RFNCCAB model) { EMI mEMI = new EMI(); List <EMI> lmEMI = new List <EMI>(); ICC mICC = new ICC(); List <ICC> lmICC = new List <ICC>(); TAC mTAC; List <TAC> lmTAC = new List <TAC>(); mEMI.EMI_1 = mRCO.COEXID; mEMI.EMI_2 = mRCO.CVATNM; mEMI.EMI_3 = mRCO.COAUTN; mEMI.EMI_4 = mRCO.COAUTB; mEMI.EMI_6 = mRCO.CMPNAM; mEMI.EMI_10 = mRCO.CMPAD1; mEMI.EMI_11 = mRCO.COSTE; mEMI.EMI_12 = mRCO.COADR3; mEMI.EMI_13 = mRCO.CMPOST; mEMI.EMI_15 = mRCO.COCRCC; mEMI.EMI_18 = mRCO.CMPAD1; mICC.ICC_1 = mRCO.COCRNO; mICC.ICC_3 = mRCO.CMPOST; mICC.ICC_5 = mRCO.COSTE; mICC.ICC_6 = mRCO.CMPAD1; mICC.ICC_7 = mRCO.COCRCC; mICC.ICC_8 = mRCO.COADR4; lmICC.Add(mICC); mEMI.LMdlICC = lmICC; lmZCC = dZCC.GetTablesRut(); foreach (ZCC item in lmZCC) { mTAC = new TAC() { TAC_1 = item.CCCODE }; lmTAC.Add(mTAC); } mEMI.LMdlTAC = lmTAC; lmEMI.Add(mEMI); return(lmEMI); }
public HttpResponseMessage GetMonthlyEMI(int id, int schemeNo) { try { Product selectedProduct = financeEntities.Products.Find(id); if (selectedProduct == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No Prouduct Found")); } EMI scheme = financeEntities.EMIs.Find(schemeNo); if (scheme == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "EMI Scheme Not Found")); } int emiCost = CalculateMonthlyEMI(selectedProduct, scheme.Months); return(Request.CreateResponse(HttpStatusCode.OK, emiCost)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
private void GuardarFactorCrimidiagnostico() { try { var Name = "Factor Criminodiagnostico"; if (emiActual != null) { short def = 0; var factor = new EMI_FACTOR_CRIMINODIAGNOSTICO(); factor.ID_EMI = emiActual.ID_EMI; factor.ID_EMI_CONS = emiActual.ID_EMI_CONS; if (EgocentrismoSelected != -1) { factor.EGOCENTRISMO = EgocentrismoSelected != null ? EgocentrismoSelected.Value : def; } if (AgresividadSelected != -1) { factor.AGRESIVIDAD = AgresividadSelected != null ? AgresividadSelected.Value : def; } if (IndiferenciaAfectivaSelected != -1) { factor.INDIFERENCIA_AFECTIVA = IndiferenciaAfectivaSelected != null ? IndiferenciaAfectivaSelected.Value : def; } if (LabilidadAfectivaSelected != -1) { factor.LABILIDAD_AFECTIVA = LabilidadAfectivaSelected != null ? LabilidadAfectivaSelected.Value : def; } if (AdaptacionSocialSelected != -1) { factor.ADAPTABILIDAD_SOCIAL = AdaptacionSocialSelected != null ? AdaptacionSocialSelected.Value : def; } if (LiderazgoSelected != -1) { factor.LIDERAZGO = LiderazgoSelected != null ? LiderazgoSelected.Value : def; } if (ToleranciaFrustracionSelected != -1) { factor.TOLERANCIA_A_LA_FRUSTRACION = ToleranciaFrustracionSelected != null ? ToleranciaFrustracionSelected.Value : def; } if (ControlImpulsosSelected != -1) { factor.CONTROL_DE_IMPULSOS = ControlImpulsosSelected != null ? ControlImpulsosSelected.Value : def; } if (CapacidadCriminalSelected != -1) { factor.CAPACIDAD_CRIMINAL = CapacidadCriminalSelected != null ? CapacidadCriminalSelected.Value : def; } if (PronosticoIntrainstitucionalSelected != -1) { factor.PRONOSTICO_INTRA_INST = PronosticoIntrainstitucionalSelected != null ? PronosticoIntrainstitucionalSelected.Value : def; } if (IndiceEstadoPeligrosoSelected != -1) { factor.INDICE_ESTADO_PELIGROSO = IndiceEstadoPeligrosoSelected != null ? IndiceEstadoPeligrosoSelected.Value : def; } if (UbicacionClasificacionCriminologicaSelected != -1) { factor.UBICACION_CLASIF_CRIM = UbicacionClasificacionCriminologicaSelected != null ? UbicacionClasificacionCriminologicaSelected.Value : def; } factor.DICTAMEN = Dictamen; if (emiActual.EMI_FACTOR_CRIMINODIAGNOSTICO == null) { if (PInsertar) { var emi = new EMI() { ID_EMI = emiActual.ID_EMI, ID_EMI_CONS = emiActual.ID_EMI_CONS, ESTATUS = "C", FEC_CAPTURA = emiActual.FEC_CAPTURA }; if (new cEMIFactorCriminodiagnostico().Agregar(emi, factor)) { emiActual.EMI_FACTOR_CRIMINODIAGNOSTICO = factor; Mensaje(true, Name); } else { Mensaje(false, Name); } } else { StaticSourcesViewModel.Mensaje("Validación", "Su usuario no cuenta con permisos para realizar esta acción.", StaticSourcesViewModel.enumTipoMensaje.MESNAJE_ADVERTENCIA, 5); } } else { if (PEditar) { if (new cEMIFactorCriminodiagnostico().Actualizar(factor)) { emiActual.EMI_FACTOR_CRIMINODIAGNOSTICO = factor; Mensaje(true, Name); } else { Mensaje(true, Name); } } else { StaticSourcesViewModel.Mensaje("Validación", "Su usuario no cuenta con permisos para realizar esta acción.", StaticSourcesViewModel.enumTipoMensaje.MESNAJE_ADVERTENCIA, 5); } } } } catch (Exception ex) { StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al guardar factor Criminodiagnóstico", ex); } }
public HttpResponseMessage PlaceOrder([FromBody] Order newOrder) { try { Consumer consumer = financeEntities.Consumers.Find(newOrder.UserName); if (consumer == null) { return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Username Is Invalid")); } Product selectedProduct = financeEntities.Products.Find(newOrder.ProductID); if (selectedProduct == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Product Could Not Be Found")); } EMI scheme = financeEntities.EMIs.Find(newOrder.SchemeNo); if (scheme == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "EMI Scheme Could Not Be Found")); } CompanyCard companyCard = financeEntities.CompanyCards.Where(c => c.UserName == newOrder.UserName).FirstOrDefault(); if (companyCard == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Conumser Card Balance Could Not Be Fetched")); } int emiCost = CalculateMonthlyEMI(selectedProduct, scheme.Months); int orderAmount = emiCost * scheme.Months; if (orderAmount > companyCard.Balance) { return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Insufficient Balance To Place Order")); } if (DateTime.Compare(companyCard.Validity, DateTime.Now) < 0) { return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Your Card Is Deactivated")); } Transaction newTransaction = new Transaction() { UserName = consumer.UserName, ProductID = selectedProduct.ProductID, SchemeNo = scheme.SchemeNo, PurchaseDate = DateTime.Now, EMIAmount = emiCost, RemainingAmount = orderAmount - emiCost, LastChecked = DateTime.Now }; financeEntities.Entry(newTransaction).State = System.Data.Entity.EntityState.Added; var currentBalance = companyCard.Balance - emiCost; companyCard.Balance = currentBalance; Deduction newAmountDeduction = new Deduction() { UserName = consumer.UserName, DeductionDate = DateTime.Now, EMIAmout = emiCost, ProductID = selectedProduct.ProductID }; financeEntities.Entry(newAmountDeduction).State = System.Data.Entity.EntityState.Added; financeEntities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, "Order Placed Successfully")); } catch { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Order Could Not Be Placed")); } }
public HttpResponseMessage PostStudentCleanliness([FromBody] string studentCleanliness) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } StudentCleanlinessModel sm = JsonConvert.DeserializeObject <StudentCleanlinessModel>(studentCleanliness); EMI emi = new EMI() { EmisCode = sm.Generalmodel.Emi.EmisCode, NameOfSchool = sm.Generalmodel.Emi.NameOfSchool, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow }; db.EMIS.Add(emi); db.SaveChanges(); Comment c = new Comment() { Entity = sm.Generalmodel.Comment.Entity, SurveyID = sm.Generalmodel.Comment.SurveyID, Section = sm.Generalmodel.Comment.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, Comments = sm.Generalmodel.Comment.Comments }; db.Comments.Add(c); db.SaveChanges(); SpecialFacility sf = new SpecialFacility() { Entity = sm.Generalmodel.Specialfacility.Entity, SurveyID = sm.Generalmodel.Specialfacility.SurveyID, Section = sm.Generalmodel.Specialfacility.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, AnyFacilitiesForDisableStudents = sm.Generalmodel.Specialfacility.AnyFacilitiesForDisableStudents, Description = sm.Generalmodel.Specialfacility.Description }; db.SpecialFacilities.Add(sf); db.SaveChanges(); List <Picture> res = sm.Generalmodel.Img.Select(x => new Picture { Entity = x.Entity, SurveyID = x.SurveyID, Section = x.Section, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, Picture1 = x.Picture1 }).ToList(); db.Pictures.AddRange(res); db.SaveChanges(); StudentCleanliness tc = new StudentCleanliness() { Entity = sm.Studentcleanliness.Entity, SurveyID = sm.Studentcleanliness.SurveyID, Section = sm.Studentcleanliness.Section, Cleanliness = sm.Studentcleanliness.Cleanliness, CreatedOn = DateTime.UtcNow, ModifiedOn = DateTime.UtcNow, }; db.StudentCleanlinesses.Add(tc); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public static void GetDocumentoFromMove(int moveId) { MySqlConnection connection = null; connection = new MySqlConnection(ConnectionConfig.connectionString); Console.WriteLine(ConnectionConfig.connectionString); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT " + "it_tmove.Docu_type_ID AS 'TipoDocumento', " + //Receptor "fl_tcustomer.TaxExemptNo, " + "fl_tcustomer.SS_NO, " + "idtypes.Codigo AS 'Tipo_Doc_Receptor', " + "Company_Name, " + "Cust_name, " + "it_tmove.Move_wic_Value, " + "it_tmove.Money_Conv, " + "it_tmove.Ticket_count AS 'IdDocumento', " + "it_tmove.Move_Date AS 'FechaEmision', " + "SUM(it_tdetamove.Move_Deta_Tax_Value) AS 'TotalIgv', " + "SUM(it_tdetamove.Move_Deta_Tax2_Value) AS 'TotalIsc', " + "SUM((it_tdetamove.Move_Deta_Q * it_tdetamove.Move_Deta_price)) AS 'TotalVenta' " + "FROM it_tmove " + "LEFT JOIN fl_tcustomer ON it_tmove.Cust_Id = fl_tcustomer.Cust_ID " + "INNER JOIN it_tdetamove ON it_tdetamove.Move_Deta_Move_ID = it_tmove.Move_ID " + "LEFT JOIN idtypes ON idtypes.TYPE_ID = fl_tcustomer.IDType " + "WHERE it_tmove.Move_ID = " + moveId + " " + "GROUP BY NULL;"; MySqlDataReader Reader; Console.WriteLine(command.CommandText); connection.Open(); Reader = command.ExecuteReader(); int i = 0; while (Reader.Read()) { string TipoDocumento = HelpersDatabase.GetString(Reader, "TipoDocumento"); string TaxExemptNo = HelpersDatabase.GetString(Reader, "TaxExemptNo"); string SS_NO = HelpersDatabase.GetString(Reader, "SS_NO"); string Tipo_Doc_Receptor = HelpersDatabase.GetString(Reader, "Tipo_Doc_Receptor"); string Company_Name = HelpersDatabase.GetString(Reader, "Company_Name"); string Cust_name = HelpersDatabase.GetString(Reader, "Cust_name"); decimal PrecioUnitario = HelpersDatabase.GetInt(Reader, "Move_wic_Value"); decimal Money_Conv = HelpersDatabase.GetInt(Reader, "Money_Conv"); string IdDocumento = HelpersDatabase.GetString(Reader, "IdDocumento"); string FechaEmision = HelpersDatabase.GetDate(Reader, "FechaEmision"); string HoraEmision = HelpersDatabase.GetTime(Reader, "FechaEmision"); decimal TotalIgv = Reader.GetInt32("TotalIgv"); decimal TotalIsc = Reader.GetInt32("TotalIsc"); decimal TotalVenta = Reader.GetInt32("TotalVenta"); string NombreLegal; string NroDocumento; DetasPlusTaxes detasPlusTaxes = GetDETFromMove(moveId); if (string.IsNullOrEmpty(Company_Name) && string.IsNullOrEmpty(TaxExemptNo)) { NombreLegal = Cust_name; NroDocumento = SS_NO; } else { NombreLegal = Company_Name; NroDocumento = TaxExemptNo; } string Moneda; if (PrecioUnitario == 0 && Money_Conv == 0) { Moneda = "PEN"; } else { Moneda = "USD"; } IDE iDE = new IDE() { numeracion = IdDocumento, fechaEmision = FechaEmision, horaEmision = HoraEmision, codTipoDocumento = TipoDocumento, tipoMoneda = Moneda, //numeroOrdenCompra = "", //fechaVencimiento = "", }; EMI eMI = new EMI() { //codigoPais = "", //correoElectronico = "", tipoDocId = "6",//falta departamento = Settings.Default.emDepartamento, direccion = Settings.Default.emDireccion, distrito = Settings.Default.emDistrito, nombreComercial = Settings.Default.emNombreComercial, numeroDocId = Settings.Default.emRUC, provincia = Settings.Default.emProvincia, razonSocial = Settings.Default.emNombreLegal, //telefono = "", ubigeo = Settings.Default.emUbigeo, urbanizacion = Settings.Default.emUrbanizacion, }; DRF dRF = new DRF() { numeroDocRelacionado = "", tipoDocRelacionado = "", }; CAB cAB = new CAB() { gravadas = new Gravadas() { codigo = "1002", totalVentas = "" }, inafectas = new Inafectas() { codigo = "1004", totalVentas = "" }, importeTotal = TotalVenta.ToString(), leyenda = new List <Leyenda>() { new Leyenda() { codigo = "1000", descripcion = Conversores.NumeroALetras(TotalVenta) } }, tipoOperacion = "01", totalImpuestos = new List <TotalImpuesto>() { new TotalImpuesto() { idImpuesto = "1000", montoImpuesto = TotalIgv.ToString() }, //IGV new TotalImpuesto() { idImpuesto = "2000", montoImpuesto = TotalIsc.ToString() } //ISC } }; REC rEC = new REC() { //codigoPais = "", //correoElectronico = "", //departamento = "", //direccion = "", //distrito = "", numeroDocId = NroDocumento, //provincia = "", razonSocial = NombreLegal, //telefono = "", tipoDocId = Tipo_Doc_Receptor, }; //GetDETFromMove(moveId), string output; if (TipoDocumento == "1") { Factura fac = new Factura() { IDE = iDE, EMI = eMI, REC = rEC, //DRF = , CAB = cAB, DET = GetDETFromMove(moveId).DET, //ADI }; output = JsonConvert.SerializeObject(fac, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } else { Boleta bol = new Boleta() { IDE = iDE, EMI = eMI, REC = rEC, //DRF = , CAB = cAB, DET = GetDETFromMove(moveId).DET, //ADI }; output = JsonConvert.SerializeObject(bol, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, }); } Console.WriteLine(output); } Reader.Close(); }