public Dictionary <Object, dynamic> deleteMaterialType(TipoMaterial registeredMaterialType)
        {
            try
            {
                TipoMaterial delMaterialType = db.TipoMaterial.Find(data["id"]);

                string oldContent = delMaterialType.toString();
                delMaterialType.Eliminado = 1;
                delMaterialType.IdEstado  = Status.Inactive;
                string newContent = delMaterialType.toString();

                db.Entry(delMaterialType).State = System.Data.Entity.EntityState.Modified;

                Bitacora paymentLog = createLog(Log.Delete, Log.MaterialType, oldContent, newContent);
                db.Bitacora.Add(paymentLog);

                db.SaveChanges();

                return(result(Result.Processed, Result.Deleted, null));
            }
            catch (Exception ex)
            {
                return(result(Result.Failed, "Error al eliminar el registro: " + ex.Message, null));
            }
        }
        public Dictionary <Object, dynamic> insertMaterialTypeFromMaintenance()
        {
            if (String.IsNullOrEmpty(data["description"]))
            {
                return(result(Result.Failed, Result.Empty, null));
            }

            try
            {
                string oldContent, newContent;

                TipoMaterial materialType = CreateMaterialType();
                oldContent = "";
                newContent = materialType.toString();

                Bitacora materialTypeLog = createLog(Log.Insert, Log.MaterialType, oldContent, newContent);

                db.TipoMaterial.Add(materialType);
                db.Bitacora.Add(materialTypeLog);
                db.SaveChanges();

                return(result(Result.Processed, Result.Inserted, null));
            }
            catch (Exception ex)
            {
                return(result(Result.Failed, "Se ha generado un error: " + ex.Message, null));
            }
        }
        public Dictionary <Object, dynamic> modifyMaterialType(TipoMaterial registeredMaterial, TipoMaterial modifiedMaterial)
        {
            if (String.IsNullOrEmpty(modifiedMaterial.Descripcion))
            {
                return(result(Result.Failed, Result.Empty, null));
            }

            if (registeredMaterial.Descripcion.Equals(modifiedMaterial.Descripcion))
            {
                return(result(Result.Failed, Result.Same, null));
            }

            try
            {
                string oldContent = registeredMaterial.toString();
                string newContent = modifiedMaterial.toString();

                TipoMaterial newMaterialType = db.TipoMaterial.Find(modifiedMaterial.IdTipoMaterial);
                db.Entry(newMaterialType).CurrentValues.SetValues(modifiedMaterial);
                db.Entry(newMaterialType).State = System.Data.Entity.EntityState.Modified;

                Bitacora MaterialTypeLog = createLog(Log.Modify, Log.MaterialType, oldContent, newContent);
                db.Bitacora.Add(MaterialTypeLog);

                db.SaveChanges();

                return(result(Result.Processed, Result.Modified, null));
            }
            catch (Exception ex)
            {
                return(result(Result.Failed, "Error al modificar el registro: " + ex.Message, null));
            }
        }