public IActionResult Update(int IdTipoDoc, [FromBody] TipoContab entity) { try { tipoContabBusiness.Update(IdTipoDoc, entity); return(Ok(true)); } catch (Exception) { throw; } }
public IActionResult Create([FromBody] TipoContab entity) { try { tipoContabBusiness.Create(entity); return(Ok(true)); } catch (Exception) { throw; } }
public TipoContab GetTipoContab(int IdEmpresa, string TipoDoc) { try { SiinErpContext context = new SiinErpContext(); TipoContab entity = context.TiposContab.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.TipoDoc.Equals(TipoDoc)); return(entity); } catch (Exception ex) { errorBusiness.Create("GetTipoContab", ex.Message, null); throw; } }
public void Create(TipoContab entity) { try { entity.FechaCreacion = DateTimeOffset.Now; SiinErpContext context = new SiinErpContext(); context.TiposContab.Add(entity); context.SaveChanges(); } catch (Exception ex) { errorBusiness.Create("CreateTiposContab", ex.Message, null); throw; } }
public void Update(int IdTipoDoc, TipoContab entity) { try { SiinErpContext context = new SiinErpContext(); TipoContab ob = context.TiposContab.Find(IdTipoDoc); ob.TipoDoc = entity.TipoDoc; ob.NumDoc = entity.NumDoc; ob.Descripcion = entity.Descripcion; ob.Estado = entity.Estado; context.SaveChanges(); } catch (Exception ex) { errorBusiness.Create("UpdateTiposContab", ex.Message, null); throw; } }
public void Create(JObject data) { try { Comprobante entity = data["entity"].ToObject <Comprobante>(); List <ComprobanteDetalle> listEntity = data["listEntity"].ToObject <List <ComprobanteDetalle> >(); SiinErpContext context = new SiinErpContext(); using (var tran = context.Database.BeginTransaction()) { TipoContab entityTipoDoc = context.TiposContab.FirstOrDefault(x => x.TipoDoc.Equals(entity.TipoDoc)); entityTipoDoc.NumDoc++; context.SaveChanges(); entity.NumDoc = entityTipoDoc.NumDoc; entity.FechaDoc = entity.FechaDoc.ToOffset(new TimeSpan(-5, 0, 0)); entity.FechaCreacion = DateTimeOffset.Now; context.Comprobantes.Add(entity); context.SaveChanges(); Comprobante obEntity = context.Comprobantes.FirstOrDefault(x => x.NumDoc == entity.NumDoc && x.TipoDoc.Equals(entity.TipoDoc)); foreach (ComprobanteDetalle d in listEntity) { d.IdDetalleComprobante = 0; d.IdComprobante = obEntity.IdComprobante; d.FechaCreacion = DateTimeOffset.Now; } context.ComprobantesDetalles.AddRange(listEntity); context.SaveChanges(); tran.Commit(); } } catch (Exception ex) { errorBusiness.Create("CreateComprobantesContab", ex.Message, null); throw; } }