Exemple #1
0
/// <summary>
/// Edit Tipo Novedad
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
        public bool Edit(BeTipoNovedad item)
        {
            try
            {
                using (var db = new EstG2Contex())
                {
                    var tn = new TipoNovedad();


                    tn.UsuarioActualizo = "gbrito";
                    tn.FechaActualizo   = DateTime.Now;
                    tn.Nombre           = item.Nombre;
                    tn.TipoNovedadID    = item.ID;
                    tn.EstatusID        = (int)item.EstatusID;
                    db.TipoNovedad.Attach(tn);
                    db.Entry(tn).Property(x => x.Nombre).IsModified           = true;
                    db.Entry(tn).Property(x => x.EstatusID).IsModified        = true;
                    db.Entry(tn).Property(x => x.UsuarioActualizo).IsModified = true;
                    db.Entry(tn).Property(x => x.FechaActualizo).IsModified   = true;
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);

                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// Create Tipo Novedad
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Create(BeTipoNovedad item)
        {
            try
            {
                using (var db = new EstG2Contex())
                {
                    var tn = new TipoNovedad();
                    tn.Nombre      = item.Nombre;
                    tn.EstatusID   = (int)item.EstatusID;
                    tn.UsuarioCreo = "gbrito";
                    tn.FechaCreo   = DateTime.Now;
                    db.TipoNovedad.Add(tn);
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);

                throw new Exception(ex.Message);
            }
        }